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

Gui uses local script to function, but it doesn't display the same value for everyone else?

Asked by 4 years ago

I have health gui for a boss in my game. It goes up and down depending on the health. When I had a friend play the game with me, we found out that the boss's health would only change the gui if you were the one who shot it. If someone else shot it, it wouldn't change at all.

It is a local script, and I don't know how to change it into a script.

Here is my script:

wait (.1)
local visible = script.Parent.Parent.Parent.Visible
local bframe = script.Parent.Parent.Parent.Parent
while true do
    local hp = game.Workspace.Dummy.Humanoid.Health/500
    script.Parent:TweenSize(UDim2.new(hp,0,1,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.15)
    wait (0.1)
    if hp < 0.01 or hp == 0 then
        bframe.BaseFrame.Visible = false
        wait (7)
        bframe.BaseFrame.Visible = true
        script.Parent:TweenSize(UDim2.new(0,647,0,70))
        script.Parent:TweenSize(UDim2.new(hp,0,1,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.15)
        local d = game.Workspace:WaitForChild("Dummy")
        local hp = d.Humanoid.Health/300
        script.Parent:TweenSize(UDim2.new(hp,0,1,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.15)
    end
    wait (.2)
end

0
sounds like you might be damaging the boss on the client side theking48989987 2147 — 4y
0
Yes that's what I thought.. but for some reason the actual health of the boss (like the health displayed above players) is accurate, but not the gui. Just_Moop 27 — 4y
0
Are you using a BillBoardGui or SurfaceGui, or a ScreenGui? Try to put a server script in the dummy where it detects health changes using :GetPropertyChangedSignal(), and then when it changes, fire to the client to make changes on the GUI or something like that maybe. ScrubSadmir 200 — 4y
0
It is a screen gui. Just_Moop 27 — 4y

1 answer

Log in to vote
0
Answered by
srimmbow 241 Moderation Voter
4 years ago

Whenever you change the health, instead of putting that line use a remote event and use the FireServer() function and put in the the health you want to change it to.

Then, when it goes to the server, use the :FireAllClients() function to make it change for everyone's gui.

Read about remote events and FireServer and FireAllClients on Roblox Developer Hub.

0
I think what I can do is make a value and change the value when it loses health, then base the gui off the health value instead. I'll report back if that works. If not i'll try this. Thank you Just_Moop 27 — 4y
0
Can you specify what line? You only sad " When you use that line " Just_Moop 27 — 4y
0
The line when you change the health srimmbow 241 — 4y
Ad

Answer this question