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

No Events firing on death of player?

Asked by 2 years ago

Hello. I'm trying to make a feature for my FPS Game for when you die you respawn. I'm making this because i have CharacterAutoLoads off. But for some reason when they die they dont respawn. I tested this with the print thing but its not running. Anyone know the fix for this? Thanks

Code: (Local Script in StarterPlayerScripts)

local charload = game.ReplicatedStorage:WaitForChild("CharLoad")


game:GetService('Players').PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character:WaitForChild("Humanoid").Died:Connect(function()
            charload:FireServer()
        end)
    end)
end)
0
whats the other script? Cyrus_O4 45 — 2y
0
what other script? Do you mean the remote event script? googlpeopel15 55 — 2y
0
You can use the exact same script on server side, you don't need to detect it with a localscript. OwOShiba 78 — 2y
0
@OwoShiba that's genius Cyrus_O4 45 — 2y
View all comments (4 more)
0
@OwoShiba Oh. I didnt know that. googlpeopel15 55 — 2y
0
@OwoShiba wait that wouldnt work. because you can only do fireserver on the client. googlpeopel15 55 — 2y
0
Then don't FireServer. Use a bindable or do whatever you were supposed to do in this script. radiant_Light203 1166 — 2y
0
wait i have another genius idea Cyrus_O4 45 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

The problem is that you didn't specify the player when you were firing the server. But I think there is another easier way to do this.

Do what @OwoShiba said but not exactly... Instead of using a local script, use a server script and place it in the ServerScriptService. The only thing you should really change is the event parts because they are not needed. Like this:

game:GetService('Players').PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character:WaitForChild("Humanoid").Died:Connect(function()
            -- code here :D
        end)
    end)
end)

Np :)

0
You don't have to pass the player as an argument when doing :FireServer. By default, the first argument is always the player that fired it. radiant_Light203 1166 — 2y
0
ok Cyrus_O4 45 — 2y
Ad

Answer this question