|
| 17 Jun 2015 05:00 PM |
Should I use a onClick() if I have a GUI button that turns on a boat basically unanchors the base of the boat.
Would I use function onClick() base.Anchor = false end
Here's what I have in the script so far tho
engine = script.Parent.Parent button = script.Parent base = script.Parent.Parent.Parent.Parent.Base
Also what do I use to turn off the boat? (anchor the base)
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 17 Jun 2015 05:03 PM |
local player = game.Players.LocalPlayer local boat = workspace[player.Name.."Boat"] local engine = boat.Engine local base = boat.Base
gui.MouseButton1Click:connect(function() base.Anchored = false end) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
|
| 17 Jun 2015 05:04 PM |
--[[For this one, make sure you have a weld to keep the boat together when it is not anchored. Unless, it will fall apart]]--
button1 = script.Parent
button1.ClickDetector.MouseClick:connect(function() base.Anchored = false end)
--Stop the boat
button2 = script.Parent
button2.ClickDetector.MouseClick:connect(function() base.Anchored = true end)
--MAKE SURE THERE IS A CLICKDETECTOR IN BOTH BUTTONS. |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Jun 2015 05:32 PM |
| I don't want a button brick, I want a gui button that works to anchor and unanchor the base |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2015 06:09 PM |
I got it!
boat = game.Workspace.Boat button = script.Parent enginecontrol = script.Parent.Parent engine = boat.Base
function onClick(GUI) engine.Anchored = false end
script.Parent.MouseButton1Click:connect(onClick)
There's the script, but now how do I make it where if you click the button once more the engine anchors? |
|
|
| Report Abuse |
|
|
| |
|
Lineout
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 684 |
|
| |
|
| |
|
|
| 17 Jun 2015 06:13 PM |
boat = workspace.Boat engine = boat.Base button = script.Parent engineControl = button.Parent
button.MouseButton1Click:connect(function() engine.Anchored = not engine.Anchored end)
Not sure why you need to use variables for everything like that but this should work.
-The [Guy] |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2015 06:14 PM |
| I'm gonna add more things to the script |
|
|
| Report Abuse |
|
|
| |
|
Lineout
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 684 |
|
|
| 17 Jun 2015 06:16 PM |
local debounce = false
if debounce == false then debounce = true ---Anchor elseif debounce == true then debounce = false --- Un anchor end |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2015 06:22 PM |
No problem. Simple solutions for the win. :P If you don't need the variables, consider these simple 3 lines to do everything.
script.Parent.MouseButton1Click:connect(function() boat.Base.Anchored = not boat.Base.Anchored end)
-The [Guy] |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2015 06:24 PM |
Oh my gosh, sorry, messed that up. I meant this:
script.Parent.MouseButton1Click:connect(function() workspace.Boat.Base.Anchored = not workspace.Boat.Base.Anchored end)
-The [Guy] |
|
|
| Report Abuse |
|
|
Lineout
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 684 |
|
|
| 17 Jun 2015 06:24 PM |
"Part.Anchored = not Part.Anchored"
Where has that been my whole life! Thanks. |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2015 06:26 PM |
| I been playing ROBLOX since 2010 and i'm barely getting in to scripting XD! |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2015 06:26 PM |
Haha yes it is a very nice bit of logic to use. :)
-The [Guy] |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2015 11:42 PM |
engine.Anchored = not engine.Anchored
Can someone explain that line to me? I don't just want to copy and paste I want to understand it too. |
|
|
| Report Abuse |
|
|
|
| 18 Jun 2015 12:17 AM |
| If the engine is anchored it makes it unanchored and vice versa. |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2015 11:44 AM |
"not" just makes it opposite. So if the value is true, "not true" will logically mean false. Same for "not false", which means true.
So if I said
thing.Anchored = not true
I believe that should make it false. But since you are setting it to
thing.Anchored = not thing.Anchored
then it will be whatever it wasn't.
-The [Guy] |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2015 11:49 AM |
Thanks, I used it to Make a boat it canme in handy in this GUI I made, check it out http://www.roblox.com/Player-Settings-GUI-V1-item?id=260109559
Or you can use it at my game just press G |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2015 11:58 AM |
I used the same concept of anchoring a boat for this little thing I was experimenting with.
http://www.roblox.com/games/187814397/Boat-Wars-Project-just-started
-The [Guy] |
|
|
| Report Abuse |
|
|
| |
|