Hey I am making a obby with checkpoints, the problem is, when someone touch the checkpoint, everybody hear the sound he made and everybody see the checkpoint turn to green, I have already tried to to put the two following scrippts in local script but its dont work. Theres the scripts: the sound script:
local part = script.Parent
local runnable = false
local player = game.Players.LocalPlayer
game.Players.ChildAdded:Connect(function(player)
part.Touched:Connect(function(Hit)
if not runnable then
runnable = true
if Hit.Parent:FindFirstChild("Humanoid") ~= nil then
local sound = script.Parent.Checkpoint
if not sound.IsPlaying then
sound:Play(player)
end
end
end
end)
end)
the color script:
local part = script.Parent
local player = game.Players.LocalPlayer
game.Players.PlayerAdded:Connect(function(player)
part.Touched:Connect(function(Hit)
script.Parent.BrickColor = BrickColor.new("Lime green")
end)
end)
and the checkpoint script (in serverscript services):
local checkpoints = workspace:WaitForChild("Checkpoints droite")
local remoteEvent = game.ReplicatedStorage:WaitForChild("ResetStatEvent") -- Again, you can use any name here
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local stage = Instance.new("IntValue")
stage.Name = "Stage"
stage.Value = 0
stage.Parent = leaderstats
player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
wait()
char:MoveTo(checkpoints[stage.Value].Position)
hum.Touched:Connect(function(hit)
if hit.Parent == checkpoints then
if tonumber(hit.Name) == stage.Value + 1 then
stage.Value = stage.Value + 1
end
end
end)
end)
end)
-- Added code here
remoteEvent.OnServerEvent:Connect(function(plr)
if plr and plr.Character and plr.Character:FindFirstChild("Humanoid") then
local humanoid = plr.Character.Humanoid
plr.leaderstats.Stage.Value = 0
humanoid.Health = 0
end
end)
Thanks you in advance!

1 comment
Hey! TY for you answer! but its dont work a lot, in the output I have this error: "12:17:26.359 Checkpoint is not a valid member of PlayerGui "Players.wDaerkfeX.PlayerGui" thank you in advance!