Ad
Log in to vote
0

How can I edit this server to client function to access the localplayer?

Asked by 19 days ago
I need to make it so when you step on a part you get teleported to a lobby, which I already have down. It's just that the "plrservice.PlayerAdded" part keeps track of the latest player added, and not the local player. How could I edit this to fire to the Localplayer's client, not some random person who joined after you?
plrservice.PlayerAdded:Connect(function(plr)
    part1.Touched:Connect(function(hit)
        if hit.Parent:WaitForChild("Humanoid") then
            if debounce then
                debounce = false
                wait(0.8)
                ev1:FireClient(plr)
                wait(1)
                debounce = true
            end
        end
    end)
end)
0
why would you need the localplayer? you can get the player instance in other ways Kingu_Criminal 111 — 19d

1 answer

Log in to vote
0
Answered by 19 days ago

You can check if the player who touched the part is you.

plrservice.PlayerAdded:Connect(function(plr)
    part1.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChildOfClass("Humanoid") and (plrservice:GetPlayerFromCharacter(hit.Parent) == plr) then
            if debounce then
                debounce = false
                task.wait(0.8)
                ev1:FireClient(plr)
                task.wait(1)
                debounce = true
            end
        end
    end)
end)
Ad

Answer this question