What I’m trying to do is have a localscript which receives information from the server upon finishing up the transparency function, so that the debounce can be set to true when the function hasn’t started, and set to false whenever the transparency function concludes. As I wish to avoid the transparency function firing 15 times, and instead, only once.
I do set it back to 0 once the count has reached 5.
repeat task.wait(1)
Check()
local result = debounceFunction:InvokeServer(AzureOre, true)
if result then
debounce = result
end
until Count == 5
Count = 0
end)
I forgot to include this, but here’s the localscript
Hitbox.Touched:Connect(function(player)
local function Check()
if Handle:GetAttribute("IsActivated") == true and not debounce then
debounce = true
Count += 1
local Cast = workspace:Raycast(Handle.Position, Handle.CFrame.LookVector * 2)
if Cast then
if Cast.Instance.Name ~= AzureOre.Name then return end
else
return
end
end
end
repeat task.wait(1)
Check()
local result = debounceFunction:InvokeServer(AzureOre, true)
if result then
debounce = result
end
until Count == 5
Count = 0
end)
You do not need to transfer any debounce data between the server and client because the RemoteFunction will yield the Localscript until the Transparency function is finished. You should only be doing this:
repeat task.wait(1)
Check()
debounceFunction:InvokeServer(AzureOre) -- waits until OreTransparency has run
debounce = false
until Count == 5
Count = 0
Hmm… Even if changed, the loop continues and the ore sends print information 15 times…
the arguments are passed when using a previously made function
also, is the debounce system there to add a cooldown?
I wish to create a debounce that allows for the transparency function to only run once, instead of 15 times which is what I’m currently dealing with
As it turns out, I was complicating things for little reason. I only had to rename one part, and detect only that part changing transparency instead of the 14 other parts within the model. I thank you for your time, and I’m rather glad I was able to clue in what went wrong.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.