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

How do I make this script work in a localserver?

Asked by 6 years ago

It wont give me gems after i touch it

local deb = false
script.Parent.Touched:connect(function(hit)
if game.Players.LocalPlayer.Maxgems.Max.Value - game.Players.LocalPlayer.leaderstats.Gem.Value > 0 then 
if hit.Parent:FindFirstChild("Humanoid") then
if deb == false then
    for _,Player in pairs(game.Players:GetPlayers()) do
        if Player:FindFirstChild("leaderstats") then
            Player.leaderstats.Gem.Value = Player.leaderstats.Gem.Value +1
workspace.CollectSound:Play()
               script.Parent:Destroy()
    if game.Players.LocalPlayer.leaderstats.Gem.Value > game.Players.LocalPlayer.Maxgems.Max.Value then
     game.Players.LocalPlayer.leaderstats.Gem.Value = 10
    end
                    end
                end
            end
        end
    end
deb = true
wait(0.1)
deb = false
end)

No output errors

0
Please use indentation in your scripts. mightydifferent 85 — 6y
0
ffs bossay8 8 — 6y
0
create a variable "local LocalPlayer = game:GetService("Players"):FindFirstChild(hit.Parent.Name)" and use it to get the LocalPlayer. LocalPlayer does not work in a server-script User#2146 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You destroyed the parent of your script thus destroying your script. EDIT: Move your script somewhere else other than the parent of the current script.

0
this did not hep bossay8 8 — 6y
0
Edited. mightydifferent 85 — 6y
0
If you accept this answer please click the "Accept Answer" button. mightydifferent 85 — 6y
0
i tried this, and it doesnt work bossay8 8 — 6y
Ad

Answer this question