我正在使用教程来制作 HP 杆,我按照它制作了一个 T 恤(我感觉),但我的 HP 不起作用。 这是参考教程.
这是代码
local greenFrame = script.Parent.Green
local label = script.Parent.TextLabel
local tweenService = game:GetService("TweenService")
local info = TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local lastHealth = 0
while wait(1) do
if game.Players.LocalPlayer.Character then
local currentHealth = math.floor(game.Player.LocalPlayer.Character.Humanoid.Health)
local newFrameSize = UDim2.new(currentHealth/100,0,1,0)
local tween = tweenService:Create(greenFrame,info,{Size=newFrameSize})
tween:Play()
if currentHealth > lastHealth then
for i = lastHealth, currentHealth, 1 do
label.Text = tostring(i).."Hp"
wait(1/(currentHealth-lastHealth))
end
else
for i = lastHealth, currentHealth, -1 do
label.Text = tostring(i).."Hp"
wait(1/(currentHealth-lastHealth))
end
end
lastHealth = currentHealth
end
end
您很可能有一些不应该大写的内容,反之亦然。
我建议暂时散布大量
print()
语句来查看所有值是什么,以便轻松判断哪里出了问题。