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

Obby Checkpoint script whis is supposed to make a gui appear not works!?

Asked by 5 years ago

Ok so I have a obby with checkpoints and when you step on checkpoints your Stage leaderstats go up by 1 and when you die you spawn at the checkpoint but I made it when you step on it a text label appears and says Checkpoint reached! but its not working and they are 2 seperate scripts but the local scripts not working heres the script Script:

local plr = game.Players.LocalPlayer

local brick = script.Parent

brick.Touched:Connect(function(hum)
    hum = hum.Parent:FindFirstChild("Humanoid")
    if hum then
        plr.PlayerGui.Checkpoint.CheckpointText.Visible = true
        wait(3)
        plr.PlayerGui.Checkpoint.CheckpointText.Visible = false
    end
end)

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

You shouldn't have it in a localscript. Instead you should use :GetPlayerFromCharacter()

This would be the server script in the block:

local brick = script.Parent

brick.Touched:Connect(function(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid")
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    if hum then
        plr.PlayerGui.Checkpoint.CheckpointText.Visible = true
        wait(3)
        plr.PlayerGui.Checkpoint.CheckpointText.Visible = false
    end
end)
Ad

Answer this question