#Need help finishing script, idk how to finish it
122 messages · Page 1 of 1 (latest)
local bimdables = game:GetService("ServerStorage"):WaitForChild("Bindables")
local nightBegin = bimdables.NightBegin
local nightEnd = bimdables.NightEnd
local light1 = script.Parent.Light
local light2 = script.Parent.Light2
nightEnd.Event:Connect(function()
print("e")
light1.Color = Color3.fromRGB(19, 255, 208)
light1.Light1.Enabled = false
light2.Color = Color3.fromRGB(19, 255, 208)
light2.SpotLight.SpotLight.Enabled = false
end)
nightBegin.Event:Connect(function()
light1.Color = Color3.fromRGB(0, 0, 0)
light1.Light1.Enabled = true
light2.Color = Color3.fromRGB(0, 0, 0)
light2.SpotLight.Enabled = true
end)
nightBegin.OnServerEvent:Connect(nightBegin)
nightEnd.OnServerEvent:Connect(nightEnd)
local bind = game:GetService("ServerStorage").Bindables
local nightStart = bind.NightBegin
local nightEnd = bind.NightEnd
local ClockTime = game.Lighting.ClockTime
while task.wait(0.1) do
if ClockTime >= 7.1 and ClockTime <= 7.2 then
nightEnd:Fire()
elseif ClockTime <= 18 and ClockTime >= 18.1 then
nightStart:Fire()
end
end
h
e
l
p
m
e
:)
whats bad
between why two bindableevents when can be one
and a bindable event doesnt receive a onserverevent
receives an "Event"
in the first script you were trying to connect the events to themselves. when using :Connect method, a function is required for it to work and from what i can see here nightBegin and nightEnd arent functions, theyre bindable events
** You are now Level 5! **
i never said they are functions, but how would i make these two work? they dont right now
yes you never stated they were functions but
nightBegin.OnServerEvent:Connect(nightBegin)
nightEnd.OnServerEvent:Connect(nightEnd)
is incorrect because there is no nightBegin() or nightEnd() function but either way you dont have to type these because nightBegin.Event:Connect and nightEnd.Event:Connect should be already enough to work
@errant glacier i can show the original script if you need to see it, it didnt work
yes thatd be appreciated
@errant glacier i couldnt get the original script but i tried my best to get it to how it was (the remote events have been changed to bindables because thats how they were)
local bimdables = game:GetService("ServerStorage"):WaitForChild("Bindables")
local nightBegin = bimdables.NightBegin
local nightEnd = bimdables.NightEnd
local light1 = script.Parent.Light
local light2 = script.Parent.Light2
nightEnd.Event:Connect(function()
print("e")
light1.Color = Color3.fromRGB(19, 255, 208)
light1.Light1.Enabled = false
light2.Color = Color3.fromRGB(19, 255, 208)
light2.SpotLight.SpotLight.Enabled = false
end)
nightBegin.Event:Connect(function()
light1.Color = Color3.fromRGB(0, 0, 0)
light1.Light1.Enabled = true
light2.Color = Color3.fromRGB(0, 0, 0)
light2.SpotLight.Enabled = true
end)
local bind = game:GetService("ServerStorage").Bindables
local nightStart = bind.NightBegin
local nightEnd = bind.NightEnd
local ClockTime = game.Lighting.ClockTime
while task.wait(0.1) do
if ClockTime >= 7.1 and ClockTime <= 7.2 then
nightEnd:Fire()
elseif ClockTime <= 18 and ClockTime >= 18.1 then
nightStart:Fire()
end
end
could you check light2.SpotLight.SpotLight.Enabled inside nightEnd.Event function?
maybe it could be light2.SpotLight.Enabled instead of that
oh, yeah that flew right over me, that would be a problem
let me fix that
i fixed that, but it still wont turn on
hmm, no errors in the output either?
no
hmm it could be because of the overcalling of events
how could i avoid that?
firing events with a loop as fast as 0.1 secs could be affecting that
but
that doesnt matter
you just need a variable that will limit an event fire for 1 time
so
in theory this script should be working
yes it should
what script would i put it on, this one?
yes
alright
sorry about that, here is the script
local bind = game:GetService("ServerStorage").Bindables
local nightStart = bind.NightBegin
local nightEnd = bind.NightEnd
local ClockTime = game.Lighting.ClockTime
local Variable = true
while task.wait(0.1) and Variable do
if ClockTime >= 7.1 and ClockTime <= 7.2 then
Variable = false
nightEnd:Fire()
elseif ClockTime <= 18 and ClockTime >= 18.1 and not Variable then
nightStart:Fire()
Variable = true
end
end
o uh
sorry if its wrong, im not great at scripting
yes exactly
but
wait
so
if you include the Variable in the while do statement with "and"
the while do loop will just loop once because Variable is defined as true
sooo okay
ah
instead of using a while do loop
you should use a GetPropertyChangedSignal
its basically like an event but any change to a property of lighting will run the code
so that the events dont have to fire every 0.1 sec
instead they will fire upon changing the clocktime
how would i change the script? this?
local bind = game:GetService("ServerStorage").Bindables
local nightStart = bind.NightBegin
local nightEnd = bind.NightEnd
local ClockTime = game.Lighting.ClockTime
local Variable = true
GetPropertyCh and Variable do
if ClockTime >= 7.1 and ClockTime <= 7.2 then
Variable = false
nightEnd:Fire()
elseif ClockTime <= 18 and ClockTime >= 18.1 and not Variable then
nightStart:Fire()
Variable = true
end
end
okay so first
we're not going to use clocktime variable
we just need the game.Lighting
to use the GetPropertyChangedSignal
it would be like this
game.Lighting:GetPropertyChangedSignal()
and wait its not done yet
inside the parenthesis we're going to insert which property thats going to be changed
in our case its clockTime
ClockTime
ok
so game.Lighting:GetPropertyChangedSignal("ClockTime")
now we have an event when the property "ClockTime" gets changed then fires a code
we're just gonna connect it to a function so
this:
game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
end)
oops
o wait nvm yea its correct
so its like that
how would i fit the bindables inside of it
nono
i mean
uh im not sure what you mean
but
youre just going to use the same code that u used in the while loop
like this
yea just copy and paste from if ClockTime ... to end
then paste it into this function
im confused
o uh
wait
local bind = game:GetService("ServerStorage").Bindables
local nightStart = bind.NightBegin
local nightEnd = bind.NightEnd
local ClockTime = game.Lighting.ClockTime
local Variable = true
game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
if ClockTime >= 7.1 and ClockTime <= 7.2 then
Variable = false
nightEnd:Fire()
elseif ClockTime <= 18 and ClockTime >= 18.1 and not Variable then
nightStart:Fire()
Variable = true
end
end)
there just like that
do i paste that in
ok
so uh i suggest u to rename Variable to isNight
does it matter?
so like if its night then isNight = true
well i mean it doesnt that much but
it helps to know what variables ur dealin with
huh it didnt work
wait bru its not done yet lol
ok
do u just want a script thats alr done or do u wanna learn how to do it
im going to hold on for a second, because i feel sick at looking at a computer screen for a while, so can you explain how to do it and show the finished script at the end?
well aight
thanks though, i appreciate it