heres the main menu script, how would I modify it so that it teleports the player?
i just don’t know how to define the player
--variables
local plr = game.Players.LocalPlayer
local char = plr.Character
local mouse = game.Players.LocalPlayer:GetMouse()
local PlayButton = script.Parent.PlayButton
local UpdateLogButton = script.parent.UpdateLogButton
local MainFrame = script.Parent
local ChangeLogFrame = script.Parent.Parent.ChangeLog
local ChangeLogButton = script.Parent.UpdateLogButton
local Players = game:GetService("Players")
mouse.Icon = 'rbxassetid://117431027'
PlayButton.MouseButton1Click:Connect(function()
MainFrame.Visible = false
-- define player
Player.Character.Torso.CFrame = CFrame.new(-819, 0.5, -51)
char.Humanoid.Health = 0
wait(0.5)
Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
end)
UpdateLogButton.MouseButton1Click:Connect(function()
ChangeLogFrame.Visible = true
end)
GolgiToad
(GolgiToad)
July 1, 2021, 3:12pm
#2
Isn’t is just HumanoidRootPart.Position? That’s what I use to walk and run.
Watching and learning.
yeah but you still have to define the player
like player.character.blah blah blah
You already define the player at the top plr
so just do plr.character.PrimaryPart.CFrame = cframe.new
Try this script:
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local char = plr.Character
local mouse = game.Players.LocalPlayer:GetMouse()
local PlayButton = script.Parent.PlayButton
local UpdateLogButton = script.Parent.UpdateLogButton
local MainFrame = script.Parent
local ChangeLogFrame = script.Parent.Parent.ChangeLog
local ChangeLogButton = script.Parent.UpdateLogButton
local Players = game:GetService("Players")
mouse.Icon = 'rbxassetid://117431027'
PlayButton.MouseButton1Click:Connect(function()
MainFrame.Visible = false
char:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new() --put position in ()
char.Humanoid.Health = 0
wait(0.5)
Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
end)
UpdateLogButton.MouseButton1Click:Connect(function()
ChangeLogFrame.Visible = true
end)
1 Like
player.Character.Torso.CFrame = CFrame.new(-819, 0.5, -51) should be
Player.Character.HumanoidRootPart.CFrame = CFrame.new(-819, 0.5, -51)
I think you need to define the Player also
You could also replace “Player” with plr
i think that would just teleport player’s camera
1 Like
lxuca
(lxuca)
July 1, 2021, 3:20pm
#8
Due to how Roblox replication works, you can technically teleport the local player (whilst ill advised) on the client.
To teleport a player, you need to move the PrimaryPart of their character, which is called the “HumanoidRootPart”. You can either set it’s CFrame or Position.
I would suggest setting the CFrame, as that considers factors like orientation and such.
The way I would suggest is using SetPrimaryPartCFrame
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
Character:SetPrimaryPartCFrame(workspace.Part.CFrame)
Hope this helps! Let me know if you need any other help.
3 Likes
GolgiToad
(GolgiToad)
July 1, 2021, 3:21pm
#9
HumanoidRootPart is attached to Character (aka char)
Now, the fun part is I always have to put wait(1) before calling the character. For some reason, WaitForChild doesn’t like my Character.
GolgiToad
(GolgiToad)
July 1, 2021, 3:23pm
#10
“CharacterAdded” may be the command I was missing… will test.
well eh when i moved humanrootpart when playtesting, it teleports the camera
lxuca
(lxuca)
July 1, 2021, 3:27pm
#12
That shouldn’t happen - are you sure you are setting the HumanoidRootPart of the player’s character?
GolgiToad
(GolgiToad)
July 1, 2021, 3:28pm
#13
You are setting health to 0. Didn’t you just kill your character?
i think i leaked a bit of my infomation but uh whatever
1 Like
GolgiToad
(GolgiToad)
July 1, 2021, 3:32pm
#15
you need to set the HRP at a height of at least the hip height (variable stored in Humanoid). I’d go a little higher, and let physics drop em in.
1 Like