I think i wrote everything rigth why is it not working Here's the script:
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then Vector3.new(5.66, 0.715, 15.34) end end)
The links above will help you understand the code below.
Here is the fix to your situation
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent:SetPrimaryPartCFrame(CFrame.new(5.66, 0.715, 15.34)) end end)
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent:MoveTo(Vector3.new(5.66, 0.715, 15.34)) end end)
This should fix your problem!
Hello here is another script that works too!
place = CFrame.new(0,0,0) -- Where you want the player to go on touched script.Parent.Touched:connect(function(p)--Creating the function local humanoid = p.Parent:findFirstChild("Humanoid")--Trying to find the humanoid if (humanoid ~= nil) then -- Checking if what touched it IS a player. humanoid.Torso.CFrame = place -- Moves the torso to what is specified in the place variable end end)--Ending the fuction, if you see on the function line above there is an unclosed parenthesis that I am closing here.
The other answers did not explain what was wrong with your script. theking48989987 gave a good explanation as to why. You called Vector3.new
but never did anything with the result of the call. So what you should do is make a model:SetPrimaryPartCFrame(cf)
call which sets the CFrame of a models primary part to the CFrame cf
.
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent:SetPrimaryPartCFrame(CFrame.new(5.66, 0.715, 15.34)) end end)
Now, the reason why to use CFrame over Vector3. M39a9am3R gave a good explanation. His explanation in short, is Vector3 factors in collision where CFrame does not. Additionally, CFrames hold both position and rotation information, so if you need to rotate the model you may if you wish.