My int value changed script is not working. I’ve placed this script in the workspace and it is a server script. (I’m not sure where to put it so…)
Goal: The int value goes up every second, so the text label should show the player’s second count
GUI script:
local intValue = game.ServerStorage.Counts.Value
local textLabel = game.StarterGui.ScreenGui.TextLabel
intValue.Changed:Connect(function()
textLabel.Text = tostring(intValue.Value)
end)
Other scripts (everything is in one script, this part is working)
local counts = game.ServerStorage.Counts
local part = game.Workspace.IntValueTest
-- counter
coroutine.wrap(function()
while true do
counts.Value = counts.Value + 1
wait(1)
end
end)()
-- event
part.Touched:Connect(function(hit)
print("you have been playing for", counts.Value, "seconds")
end)
thank you so much in advance! i really appreciate it
As mentioned above, you can not access ServerStorage from the client.
local Replicated = game:GetService("ReplicatedStorage")
local intValue = Replicated:WaitForChild("Counts")
local textLabel = script.Parent.ScreenGui.TextLabel -- your path to that label from the script.
intValue.Changed:Connect(function()
textLabel.Text = tostring(intValue.Value)
end)
I also noticed:
You defined intValue as the Value itself.
And inside the Changed event you try to set the text into the Value of the value. Which wont work.
Try what I sent above.