✓ Accepted answer
There are a few problems; let's go through them in order.
1.
:connect() is now deprecated (this may not work as expected and could be removed at any time). Instead, use :Connect().
The difference is capitalising the C.
2.
As DemonizedOverlord said, you need to check for the HumanoidRootPart before actually getting it, as it will error if you try to get something that doesn't exist.
script.Parent.Touched:Connect(function(Hit)
local Root = Hit.Parent:FindFirstChild("HumanoidRootPart")
if Root then
end
end)
3.
There is no need to add a hit. before using the humanoid variable (AKA Root in my code).
This will just make the code look for a child named humanoid inside hit, which isn't what you want, and will usually throw an error.
Root.CFrame = Value
4.
You did not create a CFrame correctly. You must use the CFrame.new() function, not the library (table) it is stored in.
script.Parent.Touched:Connect(function(Hit)
local Root = Hit.Parent:FindFirstChild("HumanoidRootPart")
if Root then
Root.CFrame = CFrame.new(game.Workspace.SpawnLocation.Position)
end
end)
Hope I helped!
~TDP
1 comment
ty