#need some help making a script not run until a lil button gets pressed

1 messages · Page 1 of 1 (latest)

chilly agate
#

i tried a lot of different stuff but script either breaks fully or button no work :(
ty :D

indigo flax
#

what do you mean by it breaking? couldn't you just connect your script to listen until the button gets pressed?

indigo flax
#

are you using a click detector to determine when the button is presed?

chilly agate
#

yes

hidden capeBOT
#

studio** You are now Level 4! **studio

chilly agate
#

i most certaintly is

#

what does this meaneth

indigo flax
#

it means that it fires an event when it's clicked

#

and you can connect a function to that event to start your script

#

do you need an example, documentation, or just wanna try it yourself?

chilly agate
indigo flax
#

give me a sec

#

this is an alternative

#

just reference your click detector and perform whatever action you need to do

chilly agate
#

ty

chilly agate
# indigo flax

what if it is a full script i need running not just a text thing

indigo flax
#

then you can changed the disabled property on scripts

#

or parent a script to an area it can execute

unique coral
#

Require the script first ofc

chilly agate
unique coral
#

basically you got 2 modules script

chilly agate
#

yes

unique coral
#

the first one is already initialized by the loader module and the other one is required by your first module but the function called Initialize is not triggered until you press button on your first module script

chilly agate
#

ok ty

#

ill do this after sleep

unique coral
# chilly agate ok ty

its smth like ->
[First Module]

local SecondModule = Require(script.SecondModule)

clickDetector.MouseClick:Connect(function()
SecondModule.Initialize()
end)

[Second Module]

SecondModule = {}

local function onClicked()
print(action received)
end

Function SecondModule.Initalize()
onClicked()
end)

Return {}

#

apply this only if you use module scripts

#

else listen the other guy

#

but this can avoid you some errors like if we take exemple of map loader if in the second script you try to locate as variable local House = Workspace.House but the house is not loaded yet you will get a error and it will break it but with the Initialize Method you can do what ever you want

chilly agate
#

:O

chilly agate
#

hey @indigo flax i tried both of these

#

no workey

indigo flax
#

hmm?