Hello, I am trying to create a script that makes a health bar go down after a sand block gets clicked. Here is the server script:
game.ReplicatedStorage.ChangeSandGui.OnServerEvent:connect(function(player, x)
local part = game.Workspace.Sand[x]
part.Health.Value = part.Health.Value - 2
local val = part.Health.Value
local value = val/10
player.PlayerGui.SandHealth.Frame.TextLabel:TweenSize( UDim2.new(value,0, 1,0))
if val <= 0 then
wait(.9)
part:Destroy()
end
end)
When I test it in studio, everything works. When I play on a normal server, the output says "SandHealth is not a valid member of PlayerGui". Any ideas why it isn't working?

5 comments
You can't access the PlayerGui from the server in FE. User remotes to update the GUI.
Do I need a script in the remote event? I dont really understand how this works
http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions and https://www.youtube.com/watch?v=4Dc_bri9mjs&t=
Thanks for the replies. This is a script fired by a remote event that’s why I have no idea how this will work
You really don't need the server side at all.