I am trying to make a script, where if the Value is true, then a Event Fires.
This script used to works, but now does not, and i have no idea how to fix it.
I have tried alot of different scripts, with help of other people and nothing worked.
Currently, what i am trying to do is.
If enabled2 is true, then script continues, that works.
if display2 is visible, then script continues, that works.
if touche2 is touched, then script continues, that works.
if doorsoundRvalue changed to True, then the script fires an event.
When the Value is true in game, it has to fire an event, but it does not do anything.
the Value changes Mid Game.
function touchedPartE2(touchE2)
if Enabled2 == true then -- works
if Display2.TextTransparency == 0 then -- works
if touchE2.Name == "EndRoute2" then -- works
if DoorSoundRValue.Value == true then -- value changes, event does not fire, or does not print anything.
print("doors opening event fired") -- not printing
EndRouteEvent2:FireAllClients() -- not firing
elseif Display2.TextTransparency == 1 then -- works
end
end
end
end
end
script.Parent.Touched:Connect(touchedPartE2)
When is DoorSoundRValue.Value changed? Is it changed on the same side of the client-server boundary as this script? You can try using another line of code outside of the function for debugging to check:
DoorSoundRValue:GetPropertyChangedSignal("Value"):Once(function()
print("Value has been changed.")
end)
Can you add an else branch to this selection statement and print all the values? It’ll help for debugging.
That’s basically just a free syntax error… it’s not an issue with the .Touched event either.
Yes, the Value changes on the Serverside aswell as the script that fires the event.
The Value can change multiple times to true, but the event can only be fired, when it is touching the TouchE2.
The Script you sent that has :GetPropertyChangedSignal, gets printed and works.
I just dont know how to add it into the function that fires the event.
ive added prints everywhere, and this is the output,
its only the event firing that is not printing.
I tried Editing Like this, but it still wonr fire the event.
DoorSoundRValue:GetPropertyChangedSignal("Value"):Connect(function()
isDoorSoundPlaying = DoorSoundRValue.Value
print("Value Changed!!!!!")
end)
function touchedPartE2(touchE2)
if Enabled2 == true then
print("enabled")
if Display2.TextTransparency == 0 then
print("display correct")
if touchE2.Name == "EndRoute2" then
print("end touched")
if isDoorSoundPlaying then -- Check the updated value
print("event fired")
EndRouteEvent2:FireAllClients()
end
end
end
end
end
script.Parent.Touched:Connect(touchedPartE2)
The print(“Value Changed!!!”) works.
but when i am touching TouchE2 and then do it, nothing prints
I think what the problem is, that the TouchE2 only prints when i first touch it.
But the value is on a moving object, so the value changes after the TouchE2 gets touched, and is still being Touched.