Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is wrong with this wont teleport when you click the gui?

What is wrong with this? I want the localscript to work. What I mean is when you click the gui you teleport to that place. How do you do this?

position = Vector3.new(0,0,0) -- CHANGE THIS TO THE POSITION

script.Parent.Button1Click:connect(function()
game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(position)
end)

2 answers

That's because the event name for a mouse click in a GUI is MouseButton1Click. Button1Click is the name of the event in the Mouse class.

7 comments

0

so i put script.Parent.MouseButton1Click:connect(function() and im good?

0

Yep

0

works

0

Ok so one more thing how can I make it randomly choose a position to spawn for example, position = Vector3.new(0,0,0) and then theres 3 more that have different (34,45,0), so when the player clicks the gui it wont spawn just in one place it will spawn in one of those 3 randomly. How can I do that? Thank you.

0

Use a table to store the positions then randomly select one from the table position = {Vector3.new(0,0,0),Vector3.new(34,45,0) } script.Parent.MouseButton1Click:connect(function() game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(position[math.random(#position)]) end)

0

whats a table sorry if this sounds dumb

Well, here is a script I made. It works very well.

function Click()																 
script.Parent.Parent.Parent.Parent.Character.Torso.CFrame = CFrame.new(1.908, 8.763, 692.483) --change to your pos
end --add three digits to the middle number. (Ex. 8.763 + 3 = 8.766) trust me, do it

script.Parent.MouseButton1Down:connect(Click)

This discussion is preserved as it was. New answers, comments, and votes are closed.