Hello guys i have another issue when i tried to help @PuffyJasonrocks84.
However the issue is when i type “Humanoid” it just won’t let it work.
The script:
--// Settings \\--
local ReplicatedStorage = game:FindFirstChild("ReplicatedStorage")
local Players = game.Players
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character
--// Scripting the Character \\--
if Character.Humanoid.Health == 0 then
-- Add anything in here !
end
Couldn’t find any images because it already says it on the title.
Thanks for the suggestion at last, i putted on StarterPlayerScripts and somehow didn’t not worked but with the suggestion to put the LocalScript from StarterPlayerScripts to StarterCharacterScripts it worked perfectly fine, although, i just wanted to make a Part but when you die it actually spawn the Part in Workspace that can’t be collected until you respawn.
Oh, That’s still simple What you could do is to detect when the Character gets added, (Fires when the Player joins the game and When the Player resets to)
Add a Server script inside of ServerScript Serivce.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
-- the Player character got added.
end)
end)
script.Parent.Humanoid.Died:Connect(function()
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
-- the Player character got added.
end)
end)
end)
Like no. You need to connect an event to Humanoid death AND wait for the humanoid to be there when you try to access it ( Also what are those comments lol ).
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
Character:WaitForChild("Humanoid").Died:Once(function()
-- Add anything in here !
end)