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

How i make the brick follow the other one but not in the middle ?

Asked by
Simnico99 206 Moderation Voter
8 years ago

Its in a LocalScript and its a lifebar follow the screen rotation the green bar (LifeBar) Resize as the life of the player diminish but when i do so it repositionate it in the middle

PlayerName = game.Players.LocalPlayer.Name
game.workspace:WaitForChild(PlayerName)
game.workspace[PlayerName]:WaitForChild("Humanoid")
game:GetService("RunService").RenderStepped:connect(function()
local PosX = game.workspace[PlayerName].Head.CFrame.x
local PosZ = game.workspace[PlayerName].Head.CFrame.z
local PosY = game.workspace[PlayerName].Head.CFrame.y   
local Matht = game.workspace.PlayerLife.LIfeRed.Position.X / 100    
local HumHealth = game.workspace[PlayerName].Humanoid.Health
local HumMaxHealth = game.workspace[PlayerName].Humanoid.MaxHealth
local HealthP = HumHealth * 100 / HumMaxHealth
local HealthPR = HealthP - math.floor(HealthP) >= 0.5 and math.ceil(HealthP) or HealthP - math.floor(HealthP) < 0.5 and math.floor(HealthP)
local LifeSize = (HealthPR * 0.04) 
local AngleX, AngleY, AngleZ = workspace.CurrentCamera.CFrame:toEulerAnglesXYZ()
local Rotation = CFrame.Angles(AngleX, AngleY, AngleZ)
local SizeX = game.workspace.PlayerLife.LifeBar.Size.X

game.workspace.PlayerLife.LIfeRed.CFrame = Rotation + Vector3.new(PosX, PosY + 1, PosZ)

local LifePosX = HealthPR * (game.workspace.PlayerLife.LIfeRed.Position.X / 100)
print(LifePosX)

game.workspace.PlayerLife.LifeBar.CFrame = Rotation + Vector3.new(PosX, PosY + 1, PosZ)

game.workspace.PlayerLife.LifeBar.Size = Vector3.new(LifeSize, 0.4, 0.4)
end)

Answer this question