hmm… still try it, it might work
Yes, that would work correctly do it
It still adds for both players now.
My scripts add for one player and do as I said and everything will work correctly.
if everything doesn’t work, try that again, I’ve updated my post.
Could you at least explain the changes so the OP knows what are you editing?
The script on the client changes the BrickColor
of the checkpoint when touched. This ensures that only the touching player sees the color change.
The server script remains responsible for updating the player’s stage stat when they hit the checkpoint.
Using AI for scripts and responses is not a good practice, there is also unnecessary changes that was added to ur script.
Its green for both players and adds the stat for both players. Have I done this right?
I can add some debug code if that helps.
add some debug code and let me know alright?
I just updated the existing code and provided full code for easy access bro
Try this:
Server Script with RunContext to LEGACY (Don’t switch Client)
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local checkpoint = script.Parent
local Debounces = {}
function onTouched(hit)
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player and character:FindFirstChildOfClass("Humanoid") then
if not Debounces[player.UserId] then
Debounces[player.UserId] = true
local checkpointData = ServerStorage:FindFirstChild("CheckpointData")
if not checkpointData then
checkpointData = Instance.new("Folder")
checkpointData.Name = "CheckpointData"
checkpointData.Parent = ServerStorage
end
game.ReplicatedStorage.Stage:FireClient(player,checkpoint,script.Sound)
local userIdString = tostring(player.UserId)
local checkpointValue = checkpointData:FindFirstChild(userIdString)
if not checkpointValue then
checkpointValue = Instance.new("ObjectValue")
checkpointValue.Name = userIdString
checkpointValue.Parent = checkpointData
player.CharacterAdded:Connect(function(character)
wait()
local storedCheckpoint = ServerStorage.CheckpointData[userIdString].Value
character:MoveTo(storedCheckpoint.Position + Vector3.new(math.random(-4, 4), 4, math.random(-4, 4)))
end)
end
checkpointValue.Value = checkpoint
player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
print(player)
end
end
end
checkpoint.Touched:Connect(onTouched)
Local Script:
game.ReplicatedStorage.Stage.OnClientEvent:Connect(function(checkpoint,sound)
checkpoint.BrickColor = BrickColor.new("Bright green")
sound:Play()
end)
Worked perfectly! Thanks everyone for all the help.