Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Values not changing the way I want?

I've been trying for about an hour now and I'm not sure what is with this script that I'm messing up on. So this is going to subtract 1 every second from the NumberValue I placed in workspace which will affect the text in a text label. This is a serverScript placed in StarterPlayerScripts, the text label is in starter gui under a screengui and frame. Number value is in workspace.

valueThing = game.Workspace.Value.Value
plr = script.Parent.Parent.PlayerGui.TimeScreen.Frame.TextLabel.Text

while true do
	plr = valueThing
	valueThing = 500
	wait(1)
	valueThing = valueThing - 1
end


1 answer

✓ Accepted answer

Filtering Enabled is likely on, so with that being said - you can't change a player's PlayerGui from the server, you can only change it from the client. To do this you would need to fire a RemoteEvent from your server loop to a client script that changes the text. Also your loop is a bit off I believe...

Server

local valueThing = game.Workspace.Value
valueThing.Value = 500

while true do
	wait(1)
	valueThing.Value = valueThing.Value - 1
	RemoteEvent:Fire(player, valueThing.Value)
end

Client

local player = game.Players.LocalPlayer
local gui = player:WaitForChild("PlayerGui").TimeScreen.Frame.TextLabel
RemoteEvent.OnClientEvent:Connect(function(val)
	gui.Text = val
end)

https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

3 comments

0

It's OnClientEvent, not OnClientInvoked. Also might wanna tell him that he should fix his .Value property, as you changed it in the code (which is correct), but you don't mention anything about it.

0

"Filtering Enabled is likely on" =>Just for sake of correctness, filtering is now always enabled regardless of FilteringEnabled’s Value. 

0

@RubanKan Thanks for catching that

This discussion is preserved as it was. New answers, comments, and votes are closed.