Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Rapaco 0
10 years ago

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

Log in to vote
0
Answered by
Destrings 406 Moderation Voter
10 years ago

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.

0
so i put script.Parent.MouseButton1Click:connect(function() and im good? Rapaco 0 — 10y
0
Yep Destrings 406 — 10y
0
works Rapaco 0 — 10y
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. Rapaco 0 — 10y
View all comments (3 more)
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) Destrings 406 — 10y
0
whats a table sorry if this sounds dumb Rapaco 0 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

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)

Answer this question