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

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

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

4 comments

0

sounds like you might be damaging the boss on the client side

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.

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.

0

It is a screen gui.

1 answer

✓ Accepted answer

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.

3 comments

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

0

Can you specify what line? You only sad " When you use that line "

0

The line when you change the health

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