Tunnells
(PlaySage)
1
So I have code if a npc takes damage a ragdoll version teleports in its place but it teleports the npc
script.Parent.Humanoid.HealthChanged:Connect(function()
local Clone = game.ServerStorage.RakeClone
Clone.HumanoidRootPart.CFrame = game.Workspace.The_Rake.HumanoidRootPart.CFrame
Clone.Parent = game.Workspace
script.Parent.Parent = game.ServerStorage
wait(5)
script.Parent.Parent = game.Workspace
Clone.Parent = game.ServerStorage
Clone.HumanoidRootPart.CFrame = script.Parent.HumanoidRootPart.CFrame
end)
For starters, could you show more of the code, second, you should be doing
local Clone = game.ServerStorage.RakeClone:Clone()
You should also be setting the parent BEFORE the CFrame is chosen, by doing it in this order,
Clone.Parent = game.Workspace
Clone.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild("The_Rake").HumanoidRootPart.CFrame
To also help you out, you shouldn’t be doing
script.Parent.Parent = game.ServerStorage
Instead you should be doing at the very top of your script,
local ServerStorage = game:GetService("ServerStorage")
You can now do,
Clone:Destroy()
or you could use DebrisService.
Also, a question, why did you do
Clone.HumanoidRootPart.CFrame = script.Parent.HumanoidRootPart.CFrame
at the bottom of your code?
Tunnells
(PlaySage)
3
Clone is not supposed to actually clown its a ragdolled version off the model
Yes, it needs to cloned, otherwise you can only do it once, having it go back to serverstorage each time is not good and causes stress on the server.
Tunnells
(PlaySage)
5
I tried this but the rake teleports now e
script.Parent.Humanoid.HealthChanged:Connect(function()
local Rake = script.Parent
local Clone = game.ServerStorage.RakeClone:Clone()
Clone.Parent = game.Workspace
Clone.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild("The_Rake").HumanoidRootPart.CFrame
Rake.Parent = game.ServerStorage
wait(5)
Clone:Destroy()
Rake.Parent = game.Workspace
end)
Where is this script parented to?