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 script?

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

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) 

10 comments

0

That us the full code

0

is*

0

Ok, thanks man!

0

Wait it says MouseButton1Click is not a valid member of the screengui

0

Is this script a parent of the button and the button only?

0

it just on the screen gui

0

Parent it to the button you want clicked.

0

So i placed the button in the localscript?

0

No, place the script as the parent of the button

0

Im so confused Ok I have a gui and I placed the button into the localscript. Is that how?

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