Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

This int value script does not work and i have no idea why. Any help?

if timeWasted.Value == 25 then
	print("25")
	has_seconds = true
	print(has_seconds)
end
							
if has_seconds then
	-- do stuff														
end

Basically it prints 25 but then doesnt change the value of has_seconds and doesnt execute the code in the second if statement

This is a server script parented to a frame

Any help is apriciated and also thanks for reading

2 comments

0

Idk about this but you could replace has_seconds to hasseconds ?

0

the underscore makes no difference

1 answer

I think the problem is that the code only runs once, so if the time doesn't start at 25, then nothing happens because it only checks once. Try using Instance.Changed:

timeWasted.Changed:Connect(function() --runs the following code every time that the value changes
	if timeWasted.Value == 25 then
		print("25")
		has_seconds = true
		print(has_seconds)
	end
	
	if has_seconds then
	-- do stuff                                                     
	end
end)

1 comment

0

ill try it out in a second

This discussion is preserved as it was. New answers, comments, and votes are closed.