I’m trying to make it so if the variable value has changed it will fire. But, since you can’t do .Changed I’m not sure what to do. I searched up like everywhere, but I didn’t find any answers.
Thank you for reading.
Why couldn’t you just use Value Objects? That’s probably the easiest way to detect when a Value changes using the .Changed
Event
Okay you’re right it’s easier to do that I guess. Thanks.
This script would do something like what you’re trying to achieve:
local Number = 1
local Previous = Number
local RS = game:GetService("RunService")
RS.Heartbeat:Connect(function()
if Previous ~= Number then
Previous = Number
-- Do other things here
end
end)
So, I made a number value, and used .Changed, but for some reason it says:
Workspace.Rapideed.FireballFolder.FireBallscript:35: attempt to index number with 'Changed'
What’s line 35 supposed to be? Looks like you’re attempting to define the Event as a variable or something
It’s supposed to test when the value has been changed.
Script:
local Debounce = script:WaitForChild(“Debounce”).Value
Debounce.Changed:Connect(function()
Oh
You can’t reference .Value
like that, as you’re basically detecting for a Changed
event inside the Value property
Change it to this
local Debounce = script:WaitForChild("Debounce")
Debounce.Changed:Connect(function(NewValue)
--Do stuff
end)