So I am trying to make a multiplication game for my sister because she forgot multiplication and I am running into a problem that when the answer is incorrect the gui pops up that show that the answer is “correct” so here is my script for the remotes:
local RS = game:GetService("ReplicatedStorage") game.Players.PlayerAdded:Connect(function(plr) --creates check values local fld = Instance.new("Folder",plr) fld.Name = "tFs" local aLd = Instance.new("BoolValue",fld) aLd.Name = "ReadyToGo" end) --When the remote is executed it checks the values if it matches to the multiplication RS.Check.OnServerEvent:Connect(function(plr, pA, aA, aTs) local totalAm = pA * aA local matgui = plr:WaitForChild("PlayerGui"):WaitForChild("MathGui") local closetime = 5 local ch = plr:WaitForChild("tFs"):WaitForChild("ReadyToGo") --looks in if the total amount of that was in textlabels matches the textbox text if not totalAm == aTs then matgui.Frame.NTA.Visible = true matgui.Frame.NTA.Ats.Text = matgui.Frame.NTA.Ats.Text.." "..aTs --Closes the frame that pops up (when answere incorrectly) repeat matgui.Frame.NTA.Laikmatis.Text = "Šitas langelis užsidarys už: "..closetime closetime -= 1 wait(1) until closetime == 0 if closetime == 0 then matgui.Frame.NTA.Visible = false ch.Value = true end else matgui.Frame.TA.Visible = true --Closes the frame that pops up (when answered correctly) repeat matgui.Frame.TA.Laikmatis.Text = "Šitas langelis užsidarys už: "..closetime closetime -= 1 wait(1) until closetime == 0 if closetime == 0 then matgui.Frame.TA.Visible = false ch.Value = true end end end) -- Update text labels and set ch.Value to false so the function from the localscript would be able to execute again RS.Update.OnServerEvent:Connect(function(plr, pS, aS) local matgui = plr:WaitForChild("PlayerGui"):WaitForChild("MathGui") local ch = plr:WaitForChild("tFs"):WaitForChild("ReadyToGo") matgui.Frame.PirmasSkaicius.Text = pS matgui.Frame.AntrasSkaicius.Text = aS ch.Value = false end)
and here is the localscript:
local RS = game:GetService("ReplicatedStorage") local PS = script.Parent.PirmasSkaicius local AS = script.Parent.AntrasSkaicius local PSG = math.random(1, 10) local ASG = math.random(1, 10) local totAm local but = script.Parent.TextButton local plr = game:GetService("Players").LocalPlayer but.MouseButton1Click:Connect(function() totAm = script.Parent.Ats.Text local psa = tonumber(PS.Text) local asa = tonumber(AS.Text) local another = PSG * ASG local matgui = script.Parent.Parent.Parent.MathGui local closetime = 5 local ch = plr:WaitForChild("tFs"):WaitForChild("ReadyToGo") RS.Check:FireServer(PSG, ASG, totAm) --Simple check on it when the value is set true it changes the amounts while ch.Value == false do wait() if ch.Value == true then PSG = math.random(1,10) ASG = math.random(1,10) RS.Update:FireServer(PSG, ASG) end end end)