So I’m making a menu where I want the player to teleport to the house when he presses the play button in the menu but I don’t know how it’s done so I need your help
Character.HumanoidRootPart.CFrame = CFrame.new(1,5,9) -- you can change them
Create a RemoteEvent that the client will fire when it is clicked on. In the parameters, be sure to include the player.
On a server script, receive the event and use the player instance that was sent and find it’s HumanoidRootPart in the workspace. Then move the player’s HumanoidRootPart to the house.
Example:
—Client, inside of button
local plr = game.Players.LocalPlayer
local workspaceplr = game.Workspace:FindFirstChild(plr.Name)
local event = game.ReplicatedStorage.Event —You need to change this to the name of the RemoteEvent
local button = script.Parent
button.MouseButton1Click:Connect(function()
event:FireServer(workspaceplr)
end)
—Server, anywhere basically
local event = game.ReplicatedStorage.Event —You need to change this to the name of the RemoteEvent
event.OnServerEvent:Connect(function(plr)
plr.HumanoidRootPart.CFrame = CFrame.new(0, 0, 0) —Change this to the Position of where you want the player to go
end)
local teleportPart = -- the part that the character teleports to
script.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.Character.HumanoidRootPart:MoveTo(teleportPart.Position)
end)
I don’t think they asked for the player to move. They asked for the players character to be teleported.
u know how to script, don’t ya? it’s a script to teleport the character not the player
First of all, I believe you do this on the server?
Second, :MoveTo() moves it, not teleports it.
Here’s a video:
But :MoveTo makes the character walk…
That’s what you should use it for, the Humanoid
, not HumanoidRootPart
. Use CFrame.new
for teleporting HumanoidRootPart
.
it didn’t work
(MoveTo is not a valid member of Part “Workspace.ANRTNT.HumanoidRootPart”)
Did you do .MoveTo
or :MoveTo
? Also, please show what you just typed.
game.Players.LocalPlayer.Character.HumanoidRootPart:MoveTo(teleportPart.Position)
You need to find the workspace Player.
Something like this:
local plr = game.Players.LocalPlayer
local workspaceplr = game.Workspace:FindFirstChild(plr.Name)
I have those as well
Then do something like this:
workspaceplr.character.humanoidrootpart:MoveTo(teleportPart.Position)
character is not a valid member of Model “Workspace.ANRTNT”
MoveTo is a function of models, not parts, use Character:MoveTo(position) rather than Character.HumanoidRootPart:MoveTo(position)
still the same error got before
Try removing Character from the script?
humanoidrootpart is not a valid member of Model “Workspace.ANRTNT”
wow new errors keep appearing