Problem: Currently, I am looking for someone who can help me script a teleporter using a SurfaceGui Button. That when you click the button you will be teleported to a part. I know that this is basic for those professional developers.
You might want to include some more information on how you have your teleporters set up, how you want them to work, etc.
Providing this little information is basically you asking someone to make something for you with absolutely no background context.
@ScripterTutorials I’m very very sorry, I forgot to type it. I edited it.
Create a surface GUI in StarterGui and set the adornee property of that surface GUI to the part you want it displayed on.
Next, create a localscript as a child of the surface GUI text/image button and insert this code in it:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.CharacterAdded:Wait()
local PartPosition = workspace:WaitForChild(PARTNAME).Position
script.Parent.MouseButton1Click:Connect(function)
Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(Vector3.new(PartPosition))
end)
Are there any errors in the console?
There’s none.
Why are you constructing a new Vector3 out of an existing one? You could simplify this code a lot by just using the part’s original CFrame instead of making a new CFrame and vector3 every time.
local PartPosition = workspace:WaitForChild(PARTNAME).CFrame
script.Parent.MouseButton1Click:Connect(function)
Character:WaitForChild("HumanoidRootPart").CFrame = PartPosition
end)
Try using
Character:MoveTo(PartPosition)
It worked well! Thank you, this really helps me improves my holo.
I would also like to say if you’re teleporting to a place thats lets say inside a building you may want to use SetPrimaryPartCFrame
so you aren’t going to have people landing on the roof.
Have a look at this page and if you need any help, message me.
Please follow category guidelines in the future. This is not a place to ask for free scripts.