Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Trying to respawn a player but it is not working?

--local script

local tool = script.Parent
local localplr = game.Players.LocalPlayer
local mouse = localplr:GetMouse()
local charged = false
local deb = false 
local e = false
local cf = true
mouse.Button1Down:Connect(function()
    if e and mouse.Target ~= nil and mouse.Target.Parent:FindFirstChild("Humanoid") ~= nil then
        local plr = game.Players:FindFirstChild(mouse.Target.Parent.Name)
        if mouse.Target.Parent.Humanoid.Health == 0 and game.Players:FindFirstChild(mouse.Target.Parent.Name) ~= nil then
            script.Parent.Handle.Sound:Play()
            local plrl = mouse.Hit
            wait(26)
            if e then
                local randomnumber = 1
                if randomnumber == 1 and plr.Character.Humanoid.Health == 0 then
					script.Parent.RespawnPlr:FireServer(plr)
                    repeat
                        wait()
                    until plr.Character ~= nil
                    repeat
                        wait()
                    until plr.Character.Humanoid.Health ~= 0
                    plr.Character.Torso.CFrame = plrl
                    plr.Character.Humanoid.Walkspeed = 0
                    plr.Character.Humanoid.Jumppower = 0
                    wait(script.Parent.Handle.Sound.TimeLength - 26)
                    if randomnumber == 1 then
                        plr.Character.Humanoid.Walkspeed = 16
                        plr.Character.Humanoid.Jumppower = 50
                    end
              	end
            end
        end
    end
end)
tool.Equipped:connect(function()
	e = true
end)
tool.Unequipped:connect(function()
	e = false
	script.Parent.Handle.Sound:Stop()
end)
script.Parent:WaitForChild("RespawnPlr")


Si i created this script but if i try on different times the LoadCharacter() that's not working i want to respawn the targeted player? Could anyone help?

2 comments

0

LoadCharacter only works in the server.

0

Ohh so not in a item? So can i try this? And i added a remote event in it but what do i need to put in a normal script in the remoteevent

1 answer

✓ Accepted answer

You can not use :LoadCharacter() on the client. If you want to respawn a player with a tool, you would have to create a remote and fire it, but i do not recommend to do so since exploiters might use it to spam/annoy other players. If you REALLY need it you could add some serversided checks but they might not fully protect you.

6 comments

0

i's a local script

0

This should be a comment. Also stop copying me.

0

I edited it but what do i need to do in the script that i put in the Remote Event RespawnPlr?

0

How exactly am i copying you? LOL

0

lau can u help me still? look now at the script and what do i need to place in the remote evnet where i placed a script?

0

???

This discussion is preserved as it was. New answers, comments, and votes are closed.