Hello.
I am making a monster in which if it touches you, your player will “disappear” making it look like the monster consumed the player (The monster is a shadow by using particle effects). I want the player to respawn after disappearing.
I tried using functions like “:Destroy()” on the player in the script but the player won’t respawn. Any way to achieve something like this?
script.Parent.Touched:Connect(function(t)
local Hum = t.Parent:FindFirstChild("Humanoid") -- Humanoid
if Hum then -- if Humanoid Exists
Hum.Health = 0 -- Kills Player
for _,i in t.Parent:GetDescendants() do -- iterates through Character
if not i:IsA("Humanoid") then -- if Instances arent a Humanoid
i:Destroy() -- Destroys Instances
end
end
end
end)
The not Removing the Humanoid is so there aren’t any errors with specific events that fire for the Humanoid
However you can just do: if i:IsA("BasePart") then
FallenPartsDestroyHeight only Destroys BaseParts so this would make an ideal sufficient script
though :LoadCharacter() can only be called from the server, you can use a RemoteEvent to send a request to the server to respawn the player using a TextButton or ImageButton
note that .CharacterAutoLoads must be false in order for :LoadCharacter() to have any effect.
I implemented that in my script but it doesn’t seem to be working. I seem to die, but I don’t disappear?
Here is my script:
local SCP017 = script.Parent.Parent.ShadowPerson
local Killsound = script.Parent.Kill
local Killsound2 = script.Parent.Kill2
local Killsound3 = script.Parent.Kill3
local Killsound4 = script.Parent.Kill4
local TargetBrick = script.Parent.Parent.TargetBrick
local Particle = script.Parent.Parent.ParticleBlock.ParticleEmitter
local VictimHide = script.Parent.Parent.VictimHide
local Attacking = false
function onTouch(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) and humanoid.Health > 0 and Attacking == false then
Attacking = true
local KillSoundRandomizer = math.random(1,4)
if KillSoundRandomizer == 1 then
humanoid.WalkSpeed = 0
SCP017.WalkSpeed = 0
humanoid.WalkSpeed = 0
humanoid.Parent.HumanoidRootPart.Anchored = true
wait(1)
Particle.Size = NumberSequence.new(1,7)
wait(.6)
SCP017.Parent.HumanoidRootPart.Anchored = true
Killsound:Play()
wait(.4)
script.Parent.Touched:Connect(function(t)
if humanoid then -- if Humanoid Exists
humanoid.Health = 0 -- Kills Player
for _,i in humanoid.Parent:GetDescendants() do -- iterates through Character
if not humanoid:IsA("Humanoid") then -- if Instances arent a Humanoid
humanoid:Destroy() -- Destroys Instances
end
end
end
end)
VictimHide.Transparency = 0
wait(8)
humanoid.BreakJointsOnDeath = false
VictimHide.Transparency = 1
Particle.Size = NumberSequence.new(7,1)
SCP017.WalkSpeed = 50
SCP017.Parent.HumanoidRootPart.Anchored = false
end
Attacking = false
end
end
script.Parent.Touched:connect(onTouch)
I’ve never used for _,i ever so I may have messed something up.
Nevermind. I just played around with the variables and got it running. Thank you so much man! I understand a little bit more now. Thanks for everyone that took their time to reply to this thread!