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

How do you change a gui with a Remote Event?

Asked by 6 years ago

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?

0
You can't access the PlayerGui from the server in FE. User remotes to update the GUI. SebbyTheGODKid 198 — 6y
0
Do I need a script in the remote event? I dont really understand how this works Agueroooooo16 15 — 6y
0
Thanks for the replies. This is a script fired by a remote event that’s why I have no idea how this will work Agueroooooo16 15 — 6y
0
You really don't need the server side at all. hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

As hiim said, you don't need to use remote events, as you can do it all on the client. For example, instead of getting the sand block through the script's Parent, you could do something like this in a local script:

local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:Connect(function()
    if mouse.Target and mouse.Target.Name == "SandBlockNameHere" then
        --reduce health bar
    end
end)
0
thats wrong sorry sexy Gey4Jesus69 2705 — 6y
0
fixed it just for you love <3 mattscy 3725 — 6y
Ad

Answer this question