I was trying to set my detecting bool value to true. But once it is set, the following code does not trigger. I can’t really tell what’s wrong since everything is alright and the output is empty? Setting to true is a simple .Value = true. The rest works alright, since the prints work. But it just stops on this one.
isdetecting.Changed:Connect(function()
if isdetecting.Value == true then
while isdetecting.Value == true do
wait(dettspeed)
if percent.Value < dettime.Value then
percent.Value += 1
print(percent.Value)
end
if percent.Value == dettime.Value then
script.Detected.Value = true
print("found")
end
end
end
end)
1 Like
isdetecting.Changed:Connect(function()
while isdetecting.Value == true do
wait(dettspeed)
if percent.Value < dettime.Value then -- this statement is probably false
percent.Value += 1
print(percent.Value)
end
if percent.Value == dettime.Value then -- also this
script.Detected.Value = true
print("found")
end
end
end)
I believe it’s the statements that are incorrect. Can you try to change it a little to something that actually works? Try to monitor the values of percent.Value
and dettime.Value
.
dettime is already set before starting the game and percent is 0, should only change here, where it does not.
Oh and in what way are the statements wrong? Isn’t this how they are written? Or am I missing something?
That’s just an assumption. Anyways, does print(percent.Value)
print?
If it does and the latter statement doesn’t, you should utilize an else
statement instead(elseif
for extra assurance). percent.Value == dettime.Value
should be percent.Value >= dettime.Value
in case the value somehow “overflows”.
If none of them are printing and that printing in the global scope doesn’t work, it’s probably due to where the script is parented to.
Print does not work, tried with an else originally, no luck either. The script is parented to a npc and the values are it’s children
I think something that toggles isdetecting
is not coming from server but client. If it happens on client and the server is trying to detect it, nothing happens.
It’s just one server script. (character limit)