I want to make it subtract 1 from the gui every time someone clicks the button. I use it on the server so I can make it update for all players at the same time.
I can’t find the issue but it doesn’t do -1 from the text label.
I tried looking around but nothing matches my problem.
Client Script:
CheckInFrame.EcoFrame.CheckIn.MouseButton1Click:Connect(function()
local seatsLeft = CheckInFrame.EcoFrame.SeatsLeftFrame.SeatNumber
if seatsLeft.Text == "0" then
CheckInFrame.EcoFrame["Check-InBox"].Text.Text = "Full"
CheckInFrame.EcoFrame.CheckIn:Destroy()
wait(3)
WelcomeFrame.Visible = true
CheckInFrame:TweenPosition(
UDim2.new(-1, 0, 0, 0),
"Out",
"Quad",
0.5,
false
)
WelcomeFrame:TweenPosition(
UDim2.new(0, 0, 0, 0),
"Out",
"Quad",
0.5,
false
)
wait(0.5)
CheckInFrame.Visible = false
CurrentFrame = "WelcomeFrame"
LastFrame = "CheckInFrame"
CheckInFrame.Position = UDim2.new(1, 0, 0, 0)
else
ReplicatedStorage:WaitForChild("Main2"):InvokeServer("ec")
end
end)
Server Script:
local Main2 = game:GetService("ReplicatedStorage"):WaitForChild("Main2")
Main2.OnServerInvoke = function(plr, command)
if command == "ec" then
for i,v in pairs(game.Players:GetPlayers()) do
v.PlayerGui.SCIGui.Main.CheckInFrame.EcoFrame.SeatsLeftFrame.SeatNumber.Text = tonumber(v.PlayerGui.SCIGui.Main.CheckInFrame.EcoFrame.SeatsLeftFrame.SeatNumber.Text) -1
end
end
end
1 Like
You are using a remote function and if I remember correctly you need to return a value or it won’t work. You may want to try using a remote event instead.
But would that work updating for all players without them having to reopen the gui?
Yes you should be able to do that
Okay, give me a minute to set it up then i’ll tell you if it works or not.
1 Like
So if for example the seats text is set to 5 and I use it in a removeevent it puts the text to -1 so it subtracted 5 to -1
And it only happened on the client part. Not the server somewhat.
What would UDim2.new() help with? Im not sure if I understand.
So instead of subtracting 1 it sets the text to “-1”?
But I use tonumber and then I set the text to the text -1
Main3.OnServerEvent:Connect(function()
for i,v in pairs(game.Players:GetPlayers()) do
v.PlayerGui.SCIGui.Main.CheckInFrame.EcoFrame.SeatsLeftFrame.SeatNumber.Text = tonumber(v.PlayerGui.SCIGui.Main.CheckInFrame.EcoFrame.SeatsLeftFrame.SeatNumber.Text) -1
end
end)
1 Like
This may be because you are setting the number on the gui originally on the client, but then you are trying to change it on the server. You may be better off using RemoteEvent:FireAllClients because then you can subtract the number through the client.
1 Like
Fire all clients can only be called from the server. How would I make this work. Like the script?
1 Like
Fire all of the clients from here
1 Like
local Main3 = game:GetService("ReplicatedStorage"):WaitForChild("Main3")
Main3.OnServerEvent:Connect(function()
Main3:FireAllClients()
end)
Like this
1 Like
Where would the for i,v be tho?
1 Like
You don’t need that because it fires all of the clients anyways, but put this inside of a local script with the parent being “SeatNumber”
local seatNumber = script.Parent
local Main3 = game:GetService("ReplicatedStorgae"):WaitForChild("Main3")
Main3.OnClientEvent:Connect(function()
seatNumber.Text = tonumber(seatNumber.Text) - 1
end)
1 Like
It worked! Thank you so much! Really appreciate it.
1 Like
No problem! Glad to hear that it worked!