I’m making a spinning system and it works fine but theres one issue, the gui. Pretty much when you spin it shows numbers and then when its done it will show what you got and then you can close the gui that says what you got but then you spin again and then you get the power but then it doesn’t show the gui again, heres an example: https://gyazo.com/f0a3c67c4deb13faeb534c2f96f22f14
And this is my code:
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
local prize = plrgui.PrizeScreenGUI.CongratsText.PrizeText
local text = plrgui.PrizeScreenGUI.CongratsText
for i = 1,40,1 do
local r = math.random(1,11)
val.Value = r
script.Parent.Parent.Text = r
wait(0.01)
end
if val.Value == 1 then
p.AwakenScript:Clone().Parent = char
text.Visible = true
prize.Text = "Full Cowling!"
end
if val.Value == 2 then
p.FirstDarkScript:Clone().Parent = char
text.Visible = true
prize.Text = "Darkness!"
end
if val.Value == 3 then
p.GodSpeed:Clone().Parent = char
text.Visible = true
prize.Text = "GodSpeed!"
end
if val.Value == 4 then
p.PainPull:Clone().Parent = char
text.Visible = true
prize.Text = "Pain's Pull!"
end
if val.Value == 5 then
p.PunchSlam:Clone().Parent = char
text.Visible = true
prize.Text = "Super Strength!"
end
if val.Value == 6 then
p.SharinganActivScript:Clone().Parent = char
text.Visible = true
prize.Text = "Sharingan"
end
if val.Value == 7 then
p.Sixfold:Clone().Parent = char
text.Visible = true
prize.Text = "Sixfold!"
end
if val.Value == 8 then
p.SpiritBombScript:Clone().Parent = char
text.Visible = true
prize.Text = "Spirit Bomb!"
end
if val.Value == 9 then
p.TitanShift:Clone().Parent = char
text.Visible = true
prize.Text = "Titan Shifting!"
end
if val.Value == 10 then
p.mountscript:Clone().Parent = char
text.Visible = true
prize.Text = "Ice Powers!"
end
if val.Value == 11 then
p.GojoScripts.CollapsingBlue:Clone().Parent = char
p.GojoScripts.HollowPurpleAc:Clone().Parent = char
p.GojoScripts.ReversalRedAc:Clone().Parent = char
text.Visible = true
prize.Text = "Gojo!"
end
end)
If anyone could help I would be really helpful and I hope you have a great day! ;D
I assume that the gui you made deletes itself when you press the close button, I recommend you make it change the visibility to false instead so you can make it visible again whenever you need. For the code you sent though, I also recommend an improvement with it to make it cleaner.
Try this:
spinning = {}
script.Parent.RemoteEvent.OnServerEvent:connect(function(plr)
if spinning[plr.UserId] ~= nil then-- so they can't spam
return
end
spinning[plr.UserId] = true
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
local prize = plrgui.PrizeScreenGUI.CongratsText.PrizeText
local text = plrgui.PrizeScreenGUI.CongratsText
for i = 1,40,1 do
local r = math.random(1,11)
val.Value = r
script.Parent.Parent.Text = r
wait(0.01)
end
if val.Value == 1 then
p.AwakenScript:Clone().Parent = char
text.Visible = true
prize.Text = "Full Cowling!"
elseif val.Value == 2 then
p.FirstDarkScript:Clone().Parent = char
text.Visible = true
prize.Text = "Darkness!"
elseif val.Value == 3 then
p.GodSpeed:Clone().Parent = char
text.Visible = true
prize.Text = "GodSpeed!"
elseif val.Value == 4 then
p.PainPull:Clone().Parent = char
text.Visible = true
prize.Text = "Pain's Pull!"
elseif val.Value == 5 then
p.PunchSlam:Clone().Parent = char
text.Visible = true
prize.Text = "Super Strength!"
elseif val.Value == 6 then
p.SharinganActivScript:Clone().Parent = char
text.Visible = true
prize.Text = "Sharingan"
elseif val.Value == 7 then
p.Sixfold:Clone().Parent = char
text.Visible = true
prize.Text = "Sixfold!"
elseif val.Value == 8 then
p.SpiritBombScript:Clone().Parent = char
text.Visible = true
prize.Text = "Spirit Bomb!"
elseif val.Value == 9 then
p.TitanShift:Clone().Parent = char
text.Visible = true
prize.Text = "Titan Shifting!"
elseif val.Value == 10 then
p.mountscript:Clone().Parent = char
text.Visible = true
prize.Text = "Ice Powers!"
elseif val.Value == 11 then
p.GojoScripts.CollapsingBlue:Clone().Parent = char
p.GojoScripts.HollowPurpleAc:Clone().Parent = char
p.GojoScripts.ReversalRedAc:Clone().Parent = char
text.Visible = true
prize.Text = "Gojo!"
end
spinning[plr.UserId] = nil
end)