NOTE: I am NOT asking for entire scripts, I just need assistance on this topic, also, I cannot post in discussions yet.
Hello I am Kamlkaze_Kid. Anyway, I was making a story game, trying to figure out how to do make a script that would not allow players to respawn when they die until they click a button. Do you have to mess with the player scripts? If you have questions please ask.
Hey there!
Firstly you will need to check CharacterAutoLoads as false (CharacterAutoLoads is a property of Players service.) Then you will be firing a RemoteEvent to server when player presses your respawn button. The server will be listening for the RemoteEvent getting fired and whenever it is fired, you should check if the player is actually dead (by Humanoid.Health) (to prevent exploiters getting respawned if they aren’t dead) and then respawn the player who fired the event with Player:LoadCharacter().
I hope this helped!
Actually it only delays it (I turned it of when i join the game otherwise your character doesn’t load at all), (I just tested it out) is it ok to use the change RespawnTime property in a script instead?
Hmmm, I just tested in an empty baseplate and it doesn’t just delay it, my character never spawned. You must have some other scripts in your game that spawned your character. Changing the respawn time would also work, although the reset button would still kill you, you just wouldn’t respawn.
i usually disable the Death state using Humanoid:SetStateEnabled() and then when the button is clicked Re-enable it and set it state to the Death State using Humanoid:ChangeState() cuz it may be that the Player regenerated health
'''
P = script.Parent.Parent.Parent.Parent.Character.Humanoid
while true do
wait(0.1)
if P.Health == 0 then
script.Parent.Visible = true
game.Players.RespawnTime = 9999999999999999999999999999999999999
end
wait()
Is that a local script? It needs to be a server script. Also that wouldn’t work well, because that respawn time would change for everyone. try what @LukaDev_0 said.
The first parameter of SetStateEnabled is the humanoid state type, the second parameter is whether it should be enabled or not.
-- Disables the death state
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Death, false)