Alright so im trying to make a gui thing where you click and it takes you to a parts cframe. simple. but apparently im doing something wrong. heres my code:
local player = game.Players.LocalPlayer local booth = workspace:WaitForChild('Booth') local boothTel = booth.BoothTeleport script.Parent.Activated:Connect(function() if player then workspace[player.Name].HumanoidRootPart.CFrame = boothTel.CFrame player.PlayerGui.BuyBooth.Enabled = false end end)
BuyBooth is a GUI, the booth variable is a model, and boothTel is the teleport part(where people will be teleported to)
local player = game.Players.LocalPlayer local booth = workspace:WaitForChild('Booth') local boothTel = booth.BoothTeleport script.Parent.Activated:Connect(function() if player then -- You don't need to check for the client again, since your activated function pretty much already does that. player.Character.HumanoidRootPart.CFrame = boothTel.CFrame -- You forgot to use the proper hierachy (game.Players.LocalPlayer.Character.HumanoidRootPart) player.PlayerGui.BuyBooth.Enabled = false end end)
Do not use workspace[player.Name]
. Instead, use player.Character
since it's more efficient. Using the first method would break the whole script if a player named "Terrain" or any other object in your workspace joined the game.
player.Character.HumanoidRootPart.CFrame = part.CFrame