This code is basically supposed to change the character stage to the name of the checkpoint.
My problem is that the brickcolor change happens to all clients. I just want to it to happen to individual that touched the brick
The script is in starterchracterscripts. And it is a local script.
When I tested the game, I noticed that it does in fact change the checkpoint to green on client. And server still shows white. BUT every players checkpoint even if they haven’t gotten to it will change to green.
Everything else works fine. Will be adding checkpoint spawner after I figure this out.
~~ Client Side ~~
local Checkpoints = game.Workspace.Game.Obby.Checkpoints
local Debounce = false
for index, value in pairs(Checkpoints:GetChildren()) do
if value.Touched:Connect(function(part)
local partParent = part.Parent
local player = game.Players:GetPlayerFromCharacter(partParent)
local leaderstats = player.leaderstats
local playerStage = leaderstats.Stage
local playerPoints = leaderstats.Points
if tonumber(value.Name) == playerStage.Value + 1 then
if not Debounce then
Debounce = true
print("Working checkpoint!")
--value.BrickColor = BrickColor.new(0,255,0)
playerStage.Value = playerStage.Value + 1
playerPoints.Value = playerPoints.Value + 5
wait()
Debounce = false
if player then
value.BrickColor = BrickColor.new(0,255,0)
end
if player.MembershipType == Enum.MembershipType.Premium then
print("Premium you get +5 points!")
-- Take some action specifically for Premium members
playerPoints.Value = playerPoints.Value + 5
else
print("Non premium you just get + 5")
end
end
end
end) then
end
end
It does the exact same as StarterPlayerScripts, and StarterCharacterScripts. I just tested it.
I feel like I’m calling every player somehow is there a way to check this?
Ok, I think I may have a solution.
.Touched fires for everyone, because it is looking for any part that has been touched and all clients are able to detect all parts. Make your script check if the part is part of the LocalPlayer’s character, and only have the action occur then.
No I did not, I basically copied yours. And retyped it in my scripts, roblox even was giving the next syntax which normally means it’s in the right section I did use :IsADecentantOf
I was trying not to rewrite all my code in serverscript then remote function to client. As this function should be client side either way it’s under localscript. But for some reason it gets all character instead of just the one that is needed