Issue with spin system

I’m having trouble with my spin system, it’s not printing anything at all this is my script though:

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
local char = plr.Character
local root = char.HumanoidRootPart
local hum = char.Humanoid
local plrgui = plr.PlayerGui
local screen = plrgui.LuckSpinGUI.SpinButton
local p = game.Lighting.PowerScripts
local val = screen.LuckScript.Object

for i = 1,70,1 do
	local r = math.random(1,5)
	val.Value = r
	script.Parent.Parent.Text = r
	wait(0.01)
end

 
if val.Value == 1 then
	print("Value = 1")
end
if val.Value == 2 then
	print("Value = 2")
end
if val.Value == 3 then
	print("Value = 3")
end
if val.Value == 4 then
	print("Value = 4")
end
if val.Value == 5 then
	print("Value = 5")
end

end)

But when I do print (val.Value) it works but when I do this it doesn’t, any help will be really helpful and I hope you have a great day!

1 Like

just add while true do.
like this:

while true do
if val.Value == 1 then
	print("Value = 1")
end
if val.Value == 2 then
	print("Value = 2")
end
if val.Value == 3 then
	print("Value = 3")
end
if val.Value == 4 then
	print("Value = 4")
end
if val.Value == 5 then
	print("Value = 5")
end
wait(0.01)--or change to what you want.
end

is this worked?
oh wait it will just repeat if

do you have any error in output?

I wouldn’t recommend placing this in a never-ending loop within a RemoteEvent you can just do

local ValConnection 
ValConnection = Val.Changed:Connect(function(Value)
print("Value = ".. Value)
ValConnection:Disconnect()
end)

Also…

What type of value is this? A numbervalue?

just put this part inside the for loop and check r instead of val.Value
for example

for i = 1,70,1 do
	local r = math.random(1,5)
	val.Value = r
	print("Value = "..r)
	script.Parent.Parent.Text = r
	wait(0.01)
end

The value is a string value since when i first started I wanted to do letters but then it was numbers but I never ended up changing it

Your if statement is asking if string = number so it wont work

Simple fix

if val.Value == "5" then
	print("Value = 5")
end

Do you require any other/further assistance @Flaming_Lion75 ?

Oh thank you! I didn’t know thank you everyone for there help ;D

or you can do:
While true do
wait()
print(val.Value)
end

hope this helps.