Hookyto
|
  |
| Joined: 15 Jan 2010 |
| Total Posts: 80 |
|
|
| 03 Apr 2017 06:11 AM |
script.Parent.Lava.Touched:connect(function(hit) if hit:FindFirstChild("Cash") then local owner = game.Players.LocalPlayer local cash = game.Players.LocalPlayer.leaderstats.Cash if cash then cash.Value = cash.Value + hit.Cash.Value end hit:Destroy() end end)
in game the dev console displays localplayer as a nil value... |
|
|
| Report Abuse |
|
|
edenDeden
|
  |
| Joined: 29 Jul 2016 |
| Total Posts: 370 |
|
|
| 03 Apr 2017 06:31 AM |
u cant only use local player in a local script
|
|
|
| Report Abuse |
|
|
edenDeden
|
  |
| Joined: 29 Jul 2016 |
| Total Posts: 370 |
|
| |
|
Hookyto
|
  |
| Joined: 15 Jan 2010 |
| Total Posts: 80 |
|
| |
|
Hookyto
|
  |
| Joined: 15 Jan 2010 |
| Total Posts: 80 |
|
|
| 03 Apr 2017 03:38 PM |
| then how would i? ive tried GetCharacterFromPlayer |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 03:39 PM |
What are you attempting to do?.
#code print(string.rep("Lit",5)) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 03:39 PM |
"GetCharacterFromPlayer"
Umm...
|
|
|
| Report Abuse |
|
|
LaeMVP
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
|
| 03 Apr 2017 03:39 PM |
.Touched gets the character not the player.
so it would be looking for cash inside of the character model. |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 03:40 PM |
Unsub is rigtht lol.
#code print(string.rep("Lit",5)) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 03:51 PM |
script.Parent.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) local money = player:FindFirstChild("leaderstats").money if hit:IsA(player) then money.Value = money.Value + 1 end end)
#code print(string.rep("Lit",5)) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 03:51 PM |
| It doesnt invoke when a ### #### it so thats a bonus. #code print(string.rep("Lit",5)) |
|
|
| Report Abuse |
|
|
| |
|
|
| 03 Apr 2017 03:56 PM |
Woops script.Parent.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) local money = player:FindFirstChild("leaderstats").money if hit.Parent:IsA(player) then money.Value = money.Value + 1 end end)
#code print(string.rep("Lit",5)) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 03:57 PM |
no and it'll still invoke regardless of what touches it, it's just a matter of the conditional statements evaluating to true
|
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 03:57 PM |
True.
#code print(string.rep("Lit",5)) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 04:02 PM |
Well, two things can happen. 1 You aren't using FE, so then use this: #code script.Parent.Lava.Touched:connect(function(hit) if hit.Parent.Humanoid and hit.Parent:FindFirstChild("Cash", true) then --the true in the findfirstchild function will make the function search in the childrens of the childrens of the childrens, etc until it reaches a matching name local plr = game.Players:FindFirstChild(hit.Parent.Name) local cash = plr.leaderstats.Cash if cash then cash.Value = cash.Value + hit.Cash.Value end hit:Destroy() end end)
Local Player can only be used for general things like mouse icon, etc. For more specific things try what i showed you
2 You ARE using FE then: Transfer the script to server-side, best way of saying it.
I would like to thank all my helpers in the forum, except you Tommy. I don't like Tommy... |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 04:03 PM |
Lol?
#code print(string.rep("Lit",5)) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 04:03 PM |
Do you even know what you're talking about lol?.
#code print(string.rep("Lit",5)) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 04:05 PM |
| I attempted, ######## Unlike you who just posts: "Lol" I would like to thank all my helpers in the forum, except you Quantum. I don't like Quantum... |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 04:05 PM |
You're script is dumb lol honestly GetPlayerFromCharacter is so much easier and more efficent.
#code print(string.rep("Lit",5)) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 04:07 PM |
Well, i'm sorry. I'm just trying to be helpful unlike you seems to just love messing with people.
I would like to thank all my helpers in the forum, except you Quantum. I don't like Quantum... |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 04:07 PM |
You guys are overcomplicating it...
OP, I don't know if `player` is supposed to already be defined. It looks like a tycoon to me.
local player -- define this somehow; owner of tycoon? local cash = player.leaderstats.Cash -- no need to check; it's going to exist
script.Parent.Lava.Touched:Connect(function(part) local value = part:FindFirstChild("Cash") if value then cash.Value = cash.Value + value.Value end end)
|
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 04:08 PM |
You're misleading him because you dont even know what you're talking about so.
#code print(string.rep("Lit",5)) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 04:08 PM |
"no need to check; it's going to exist"
Assuming your game is FE like it should be.
|
|
|
| Report Abuse |
|
|
|
| 03 Apr 2017 04:08 PM |
(I wasnt speaking to you unsub btw)
#code print(string.rep("Lit",5)) |
|
|
| Report Abuse |
|
|