I am having a problem with my checkpoint script. As my title said. I am trying to make my obby so when a player touches a checkpoint it dissapears. But when i test the game with 2 players when the first one touches the checkpoint for the other one it is invisible and the checkpoint stops working for the first one. What i want to do is for each player to have their own script. I am new to scripting lua c on roblox.
Here is my script:
local StageValue = 0 local debounce1 = false local Touched1 = false workspace.Stages.Stage1.Touched:Connect(function(hit) if hit.Parent:FindFirstChildOfClass("Humanoid") and not debounce1 and not Touched1 then Touched1 = true StageValue = StageValue + 1 if StageValue == 1 then print("StageValue is now 1") workspace.Stages.Stage1.CanCollide = false workspace.Stages.Stage1.Transparency = 1 workspace.Stages.Stage1.Sparkles.Enabled = false local debounce1 = true end end end)
This is all in a script not a local script and the script is located in the workspace.
EDIT: You can make anything happen in the two functions below, I just update a stage value.
I did this by naming each checkpoint whatever the stage is. For instance, stage 1 is 1, stage 2 is 2, etc. I then tag all of the checkpoints as "Checkpoint" using the tag editor plugin. (A folder would also work, with some minor edits to the code.) Then the server code becomes:
local function checkpoint(Hit, Part) if Players:GetPlayerFromCharacter(Hit.Parent) then local stageNumber = Part.Parent.Name local player = Players:GetPlayerFromCharacter(Hit.Parent) player.leaderstats:WaitForChild("Stage").Value = stageNumber end end for _, Part in pairs(CS:GetTagged("Checkpoint")) do --If using a folder, do `folder:GetChildren` Part.Touched:Connect(function(Hit) checkpoint(Hit, Part) end) end CS:GetInstanceAddedSignal("Checkpoint"):Connect(function(Part) --If using a folder, do `folder.ChildAdded` Part.Touched:Connect(function(Hit) checkpoint(Hit, Part) end) end)
Hi Jozou,
local players = game:GetService("Players") local player = players.LocalPlayer local re = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent") re.OnClientEvent:Connect(function(part) part.Transparency = 1 end)
local part = script.Parent local re = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent") local players = game:GetService("Players") local deb = false part.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChildOfClass("Humanoid") local plr = players:GetPlayerFromCharacter(hit.Parent) if not deb and hum and plr then re:FireClient(plr, part) end end)
Thanks,
Best regards,
Idealist Developer