db = false
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not db then
db = true
script.Parent.BrickColor = BrickColor.new("Bright red")
local plr = player.name
game.ServerStorage.PlayerMoney.plr.Value = game.ServerStorage.PlayerMoney.plr.Value + 10
wait(3)
script.Parent.BrickColor = BrickColor.new("Bright green")
db = false
end
end
end)
COMMUNITY QUESTION
Why is this not working When I touch a brick? (Inside A script)
2 answers
on line 8 where you make the variable "plr" You never use it later on.
If you are trying to find a child in PlayerMoney with the name of the players name you should do
local plr = player.Name
game.ServerStorage.PlayerMoney:FindFirstChild(plr).Value = game.ServerStorage.PlayerMoney:FindFirstChild(plr).Value + 10
I agree with PoePoeCannon's answer, but I'll explain it a little bit more.
game.ServerStorage.PlayerMoney.plr.Value = game.ServerStorage.PlayerMoney.plr.Value + 10 isn't a valid command. if you're trying to find something by using a changing-name. (i.e. player name) you should use [] instead of a period. If this doesn't make since, then this might
game.ServerStorage.PlayerMoney[plr].Value = game.ServerStorage.PlayerMoney[plr].Value + 10
This discussion is preserved as it was. New answers, comments, and votes are closed.
