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

My health controller isn't working but it also has no errors. [?]

Asked by 6 years ago

So I'm trying to make a health bar for a custom Part. But it isn't working and there are no errors.

Here are notes:

  1. this is a Local Script inside a model. The model's parent is Workspace

Here is my script;

local HealthBar = script.Parent:WaitForChild('BlueSpawn').BillboardGui.HealthFrame.HealthBar
local HealthText = HealthBar.HealthText
local HP = script.Parent:WaitForChild('Stats').HP
local MaxHP = script.Parent:WaitForChild('Stats').MaxHP

wait()
local HealthPercentage = HP / MaxHP
HealthText.Text = HP.Value..' / '..MaxHP.Value
HealthBar.Size = UDim2.new(HealthPercentage, 0, 1, 0)

The thing is I set the HP to 100 and Max Hp to 300 but it doesn't show 100 / 300.

Perhaps I should change to server script? Please help. I'm going to add a .Changed function later so that if damaged it will be effected.

1
LocalScripts cannot run in the workspace. Consider putting it in a server script. http://wiki.roblox.com/index.php?title=API:Class/LocalScript PyccknnXakep 1225 — 6y
0
But the local script is in a model BlackOrange3343 2676 — 6y
0
It doesn't matter. They can only function in a Character Model, and services like Backpack, StarterGui, PlayerGui, PlayerScripts, and ReplicatedFirst. PyccknnXakep 1225 — 6y
0
k BlackOrange3343 2676 — 6y

Answer this question