I was wondering how I could make an optimized bush rustle script (For example, when a player touches a part named "Bush", the bush moves slightly and plays a sound) without having 300 bushes all with 1 script inside of each of them, for optimization purposes. Is there a way to make it so I can do this in 1 script and have it always do what I need it to without having a lot of scripts?
#Help with a Bush Rustle script
32 messages · Page 1 of 1 (latest)
I can help with that
use variables
thank you, I'm kinda new to scripting so this is gonna be very useful
how exactly would I use variables in this case?
link = script.parent
linkother = game.workspace.Folderwithbush
now
let me teach you what you can do with that
are u here?
you could run a for loop that goes through all of the bushes to see if they are touched, and if they are, move them.
yeah that is possible
with
while true do
if a part is activated
it can run to see if all the others are being touched
yeah I'm here
how would I do that? Only way I can think of is if statements
okay.
let me help
so
what wou want to do
is use something like this
--[[
-SCRIPT PURPOSE-
So the parts mentioned below are parts that go on and off for the heist feeling.
Second light
third light
fourth light
circlular light
What this does is it makes the lights go on and off to red neon after you enter the submarine.
--]]
link = script.Parent
otherlinks = game.Workspace["Submarine Models"].Lights
switchoff = game.Workspace.Sounds.switch_off
switchon = game.Workspace.Sounds.switch_on
eventrun = 1
--Switches lights off with the sound | This part only
wait(1)
link.Material = ("SmoothPlastic")
--Other Lights | Other parts only
otherlinks["Second Light"].Material = ("SmoothPlastic")
otherlinks["Third Light"].Material = ("SmoothPlastic")
otherlinks["Fourth light"].Material = ("SmoothPlastic")
otherlinks["Fifth Light"].Material = ("SmoothPlastic")
otherlinks["Circlular light"].Material = ("SmoothPlastic")
--Sound is played here
switchoff:Play()
wait(2)
--Switches lights back on | This part only
link.Material = ("Neon")
--Other Lights change to neon
otherlinks["Second Light"].Material = ("Neon")
otherlinks["Third Light"].Material = ("Neon")
otherlinks["Fourth light"].Material = ("Neon")
otherlinks["Fifth Light"].Material = ("Neon")
otherlinks["Circlular light"].Material = ("Neon")
--Colour Changing To red after lights go off/on | This part only
link.Color = Color3.new(1, 0, 0)
if link.Color == Color3.new(1, 0, 0) then
print("Lights Code Red", 1)
end
--Other lights changing to red | Other parts only
otherlinks["Second Light"].Color = Color3.new(1, 0 , 0)
otherlinks["Third Light"].Color = Color3.new(1, 0 , 0)
otherlinks["Fourth light"].Color = Color3.new(1, 0 , 0)
otherlinks["Fifth Light"].Color = Color3.new(1, 0 , 0)
otherlinks["Circlular light"].Color = Color3.new(1, 0 , 0)
switchon:Play()
-- Script made for ahmad by cat :)```
this is part of a script in my game
so I should use if statements?
duh
what about the position change, it should be random rotation in any direction
well first pick a random direction, point that direction, then apply a vectorforce in that direction to move