Coming soon - Get a detailed view of why an account is flagged as spam!
view details
7
Need Help With Buttons, Please!
Post Body

Hi Everyone. I'm new to Roblox Studio and although I picked up on the modeling in about a hour (20yrs of AutoCAD makes it easy), I'm having a very difficult time with the scripts. Currently, I'm trying to create an activation button to set off sprinklers for a crop field. I've been messing with it for a couple days and I believe I'm having a hard time understanding how buttons can activate a part elsewhere in the game. Here's the details:

I have sprinklers that I found in the toolbox that already had their own script to activate if you click directly on them.

Included Sprinkler Script:

-------------------------------------------------------------------------------

sound = script.Parent.Glass.Sound

sound1 = script.Parent.Glass.Sound1

sound2 = script.Parent.Glass.Sound2

water = script.Parent.Emitter.Water

mist = script.Parent.Emitter.Mist

rod = script.Parent.heatrod

a = false

s = script.Parent

mist.Enabled = false

water.Enabled = false

script.Parent.Interactive.ClickDetector.MouseClick:connect(function()

\--print("Clicked")

rod.Anchored = false

sound:Play()

wait(0.2)

sound1:Play()

mist.Enabled = true

water.Enabled = true

sound2:Play()

wait(8)

if a then return end

a = true

s.Alarm.Value = true

wait(60)

water.Enabled = false

sound:Stop()

sound1:Stop()

sound2:Stop()

mist.Enabled = false

a = false

s.Alarm.Value = false

\--print("Reset")

end)

-------------------------------------------------------------------------------

Sprinkler names:
RiceSprinkler1

RiceSprinkler2

RiceSprinkler3

RiceSprinkler4

RiceSprinkler5

RiceSprinkler6

RiceSprinkler7

RiceSprinkler8

Each sprinkler has the same script listed above attached to it.

-------------------------------------------------------------------------------

My goal is to get 8 sprinklers to activate with one button. Now for the questions:

  1. Obviously I have to write a script for the button activation. Does the button script have to include the scripts from the sprinklers? Or, can the button script reference/link to the sprinkler scripts?
  2. Do the sprinklers need to be named differently if they all do the same thing at the same time? Basically, can they all be called "RiceSprinkler" and the activation button will activate all 8 if they are named the same?
  3. I've written other scripts for power ups and traps, but those seem much more basic compared to writing a script for one part that activates multiple parts in game. That's a simple 'A' activates 'A' and what I'm not fully understanding is how 'A' activates 'B' within the script text under 'A'.

Any help/guidance is much appreciated. If you're able to write a script for me based on everything I've provided, oh boy would that be nice of you. Then at least I'd have an example for future reference seeing as I need to do this for 3 other crop fields once I have it figured out. Thank you in advance.

Author
Account Strength
100%
Account Age
4 years
Verified Email
Yes
Verified Flair
No
Total Karma
22,665
Link Karma
2,035
Comment Karma
19,919
Profile updated: 6 days ago
Posts updated: 11 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
4 years ago