Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I made a teleporting device, says I need a vector3?

Asked by 4 years ago

I tried making a tool that would teleport the player.

LocalScript:

local plr = game.Players.LocalPlayer

script.Parent.Activated:Connect(function()
    local mouse = plr:GetMouse() 
    game.ReplicatedStorage.tpPlr:FireServer(mouse.Hit.p)
end)

server script:

game.ReplicatedStorage.tpPlr.OnServerEvent:Connect(function(client, mouseCFrame)
    local humanPart = client.Character.HumanoidRootPart
    humanPart.CFrame = mouseCFrame 
end)

It said that a CFrame was expected, but got a Vector3. Anyone know the problem?

1 answer

Log in to vote
1
Answered by
Prestory 1395 Moderation Voter
4 years ago

I recommend Using :MoveTo() as the player is a model and this ensures the player does not fall through the ground without any extra code here is an example of how to use it.

game.ReplicatedStorage.tpPlr.OnServerEvent:Connect(function(client, mouseCFrame)
    local Character = workspace:WaitForChild(client.Name)
    Character:MoveTo(mouseCFrame)
end)
Ad

Answer this question