I made a button that runs a script stored in ServerScriptService with Remote Event. Within that script, has at least 2 functions. A function were called within another function. When I pressed the button once, it works as intended, but after pressing multiple times, it decide to not do anything at all or do only some of the task that was intended. I have about 3 leader stats updating every 1 to 10 sec to test the updates (not sure if this was the cause of the problems or not).
Edited: Leaderstats was not the cause of the problem, I’ve tested it.
Example of the script:
Here works fine, I love including this code because I tried to avoid players making new alt account.
game.ReplicatedStorage.Shop.OnServerEvent:Connect(function(player)
if player.AccountAge > MinimumAge then
local gui = player.PlayerGui.ShopGui
shoptime(player,gui)
print("all good")
else
print("possible alt account")
end
end)
Specifically within this function, it only worked once after the button were pressed. if the player doesn’t have enough money, it doesn’t display the box that I made. Even if the player have enough money, it only reduced players money but didn’t show the successful box display and totally ignored my DisplayDetails function within this function… Any idea why?
function shoptime(player,gui)
local money = player.moneystats.money.Value
local group
if money >= 100 then
gui.Screen.Message.Visible = false
local moneyBefore = point
money = money - 100
local moneyNow = money
player.moneystats.Points.Value = moneyNow
DisplayDetails(player,moneyBefore,moneyNow)
gui.Screen.Message.Visible = true
gui.Screen.Message.Word.Text = "Successful! "
gui.Screen.Message.Word.TextColor3 = Color3.new(0.0392157, 1, 0.101961)
else
gui.Screen.Message.Visible = true
gui.Screen.Message.Word.Text = "Not Enough! "
gui.Screen.Message.Word.TextColor3 = Color3.new(1, 0, 0.0156863)
end
end
This is the localscript within the Message GUI to close it. i wonder if its the cause of the problem for not popping out the message GUI:
function onClick()
local Close = script.Parent
if (Close.Parent.Visible)then
Close.Parent.Visible = false
else
end
end
script.Parent.MouseButton1Down:Connect(onClick)