LocalScript
:
local playerGui = game.Players.LocalPlayer.PlayerGui
local screenGui = playerGui.ScreenGui
local textLabel = screenGui.TextLabel
local intValue = screenGui.IntValue -- IntValue.Value is 0 by default.
local updateValueEvent = game:GetService("ReplicatedStorage").UpdateValueEvent -- Remote Event
local clickPart = workspace:WaitForChild("ClickPart")
local clickDetector = clickPart.ClickDetector
local function updateText()
textLabel.Text = intValue.Value
end
clickDetector.MouseClick:Connect(function(playerWhoClicked)
updateValueEvent:FireServer(playerWhoClicked)
updateText()
end)
ServerScript
:
local updateValueEvent = game:GetService("ReplicatedStorage").UpdateValueEvent
updateValueEvent.OnServerEvent:Connect(function(player)
local intValue = player:WaitForChild("PlayerGui").ScreenGui.IntValue
intValue.Value += 1
end)
The problem is that the Text
of textLabel
is set to 0
, even when the Value
of intValue
is set to 1, and the Text
is set to 1 when the Value
is set to 2, and so on.
I want to make it so whenever the Value
of intValue
is equal to a specific number, the Text
of textLabel
is equal to the same Value
, unfortunately the Text
is just set to Value
minus 1.
I tried using repeat task.wait() until intValue.Value > 0
but it still doesn’t work as intended.
Help is much appreciated!