Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

? /// + value and :Destroy() doesn't work

Asked by 5 years ago
-- Script
game.Players.PlayerAdded:Connect(function(player)
    script.Parent.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            local lead = player:WaitForChild("leaderstats")
            local food1 = lead:WaitForChild("Food Collected")
            food1.Value = food1.Value + 2
            script.Parent:Destroy()
        end
    end)
end)

if the food has been touched, it will +2 the value in leaderstats.Food Collected and Destroy() it, but it does it, but I touched about 30 of them, but only one has been destroyed and got +2 value in leaderstats. Can somebody enhance the script so that you can touch and collect(Destroy) it easily?

0
There's no need for PlayerAdded here just use :GetPlayerFromCharacter(). I never handle stuff like this from inside of the respective object, I handle from inside of ServerScriptService. SummerEquinox 643 — 5y

Answer this question