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

How to know if character respawns in a Local Script?

Asked by 3 years ago

How? I tried searching online but they do it in a Server Script not in a Local Script. CharacterAdded doesn't work in local scripts so how?

0
um maybe do it in a serverscript xd TwoTramp 18 — 3y
0
Cant becuz i will blur the screen of that player only RazorXX2 24 — 3y

3 answers

Log in to vote
0
Answered by 3 years ago
local Players = game:GetService("Players")

local Player = Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:wait()
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Use this

local Players = game:GetService("Players")

local function onCharacterAdded(character)
    -- Code when character is added
end

local function onPlayerAdded(player)
    player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

from this https://developer.roblox.com/en-us/api-reference/event/Player/CharacterAdded

edit

local Players = game:GetService("Players")

local function onCharacterAdded(character)
    -- Code when character is adeed
end

local function onCharacterRemoving(character)
    -- Code when character is removing
end

local function onPlayerAdded(player)
    player.CharacterAdded:Connect(onCharacterAdded)
    player.CharacterRemoving:Connect(onCharacterRemoving)
end

Players.PlayerAdded:Connect(onPlayerAdded)
Log in to vote
0
Answered by 3 years ago

Already fixed! Thx for the help!

Answer this question