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

What is wrong with this script?

Asked by
Rapaco 0
10 years ago

So, i placed this localscript in a screengui, and a placed a textbutton on the screengui.

position = {Vector3.new(5,5,5),Vector3.new(34,45,0)
script.Parent.MouseButton1Click:connect(function() 
game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(position[math.random(#position)]) 
end)

1 answer

Log in to vote
0
Answered by 10 years ago
position = {Vector3.new(5,5,5),Vector3.new(34,45,0)
script.Parent.MouseButton1Click:connect(function() 
game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(position[math.random(#position)]) 
end)

This code will not work because you shouldn't have a end) statement when you don't even have a starter statement, here's an example on what i think you were trying to do.

function onClick(mouse)
position = Vector3.new(5,5,5),Vector3.new(34,45,0)
game.Players.LocalPlayer.Character.Torso.CFrame =CFrame.new(position[math.random(#position)]) 
end
script.Parent.MouseButton1Click:connect(OnClick) 
0
That us the full code Rapaco 0 — 10y
0
is* Rapaco 0 — 10y
0
Ok, thanks man! Rapaco 0 — 10y
0
Wait it says MouseButton1Click is not a valid member of the screengui Rapaco 0 — 10y
View all comments (6 more)
0
Is this script a parent of the button and the button only? colefrickz 0 — 10y
0
it just on the screen gui Rapaco 0 — 10y
0
Parent it to the button you want clicked. colefrickz 0 — 10y
0
So i placed the button in the localscript? Rapaco 0 — 10y
0
No, place the script as the parent of the button colefrickz 0 — 10y
0
Im so confused Ok I have a gui and I placed the button into the localscript. Is that how? Rapaco 0 — 10y
Ad

Answer this question