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

Plane gui motor?

i have made an engine and i want it when you press on a gui to make it to start to spin i add a motor and the motor is truned off and can someone help me fix the script for it?

local Motor = script.Parent.Parent.Parent.Workspace.MOTOR.BackSurfaceInput


function onClicked
	Motor = "Constant"
end	

2 comments

0

You are missing Parentheses.

0

what you mean?

1 answer

I'm not sure what to say about how your script works as you haven't really provided much, but for functions, regardless of the existence of arguments or not, you still need dual parenthesis after your function keyword, such as function name(), rather than function name. Otherwise, the Lua interpreter will fail.

Fixed:

local Motor = script.Parent.Parent.Parent.Workspace.MOTOR.BackSurfaceInput

function onClicked()
    Motor = "Constant"
end 

You should also define your BSI when you change it, or you could experience an error. And why not use game.Workspace.MOTOR rather than a line of parents?

Fixed again:

local Motor = game.Workspace.MOTOR

function onClicked()
    Motor.BackSurfaceInput = "Constant"
end 

Also, how are you calling this function? Is this all of your script, or is just a snippet you need help with?

4 comments

0

It's much easier to do game.Workspace or better yet, workspace.

0

Didn't see that. Edited into my answer.

0

non of them seem to work

0

My script works; but you need to provide your other code if it doesn't work. Clearly something else must call this function for it to work.

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