I have a coins around a map, and when you touch it it gives you 1 coin. And plays a coin noise. It works in Test>Play solo, but not In normal game. Why doesn't it work?
Here is the script:
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
script.Parent.Bling:Play()
local score = stats:findFirstChild("Coins")
if (score~=nil) then
score.Value = score.Value + 1
script.Parent.Bling:Play()
script.Parent:Remove()
end
end
end
script.Disabled = false
end
end
script.Parent.Touched:connect(onTouched) |