HookytoJoin Date: 2010-01-15 Post Count: 80 |
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... |
|
edenDedenJoin Date: 2016-07-29 Post Count: 370 |
u cant only use local player in a local script
|
|
edenDedenJoin Date: 2016-07-29 Post Count: 370 |
can*
|
|
HookytoJoin Date: 2010-01-15 Post Count: 80 |
bump |
|
HookytoJoin Date: 2010-01-15 Post Count: 80 |
then how would i? ive tried GetCharacterFromPlayer |
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
What are you attempting to do?.
#code print(string.rep("Lit",5)) |
|
|
"GetCharacterFromPlayer"
Umm...
|
|
LaeMVPJoin Date: 2013-06-24 Post Count: 4416 |
.Touched gets the character not the player.
so it would be looking for cash inside of the character model. |
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
Unsub is rigtht lol.
#code print(string.rep("Lit",5)) |
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
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)) |
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
It doesnt invoke when a ### #### it so thats a bonus. #code print(string.rep("Lit",5)) |
|
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
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)) |
|
|
no and it'll still invoke regardless of what touches it, it's just a matter of the conditional statements evaluating to true
|
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
True.
#code print(string.rep("Lit",5)) |
|
|
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... |
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
Lol?
#code print(string.rep("Lit",5)) |
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
Do you even know what you're talking about lol?.
#code print(string.rep("Lit",5)) |
|
|
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... |
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
You're script is dumb lol honestly GetPlayerFromCharacter is so much easier and more efficent.
#code print(string.rep("Lit",5)) |
|
|
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... |
|
|
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)
|
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
You're misleading him because you dont even know what you're talking about so.
#code print(string.rep("Lit",5)) |
|
|
"no need to check; it's going to exist"
Assuming your game is FE like it should be.
|
|
CyrakohlJoin Date: 2014-11-09 Post Count: 3197 |
(I wasnt speaking to you unsub btw)
#code print(string.rep("Lit",5)) |
|