Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Values not changing the way I want?

Asked by 5 years ago

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

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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

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. RubenKan 3615 — 5y
0
"Filtering Enabled is likely on" =>Just for sake of correctness, filtering is now always enabled regardless of FilteringEnabled’s Value.  Thetacah 712 — 5y
0
@RubanKan Thanks for catching that climethestair 1663 — 5y
Ad

Answer this question