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

why isnt Thirst Script Not Working?

Asked by 8 years ago

http://prntscr.com/ac4sy9 ** Script In Thirst Bar**

local Bar = script.Parent
local Thirst = script.Parent.Parent.Parent.Parent.Hunger


function Check()

    if Thirst.Value <= 100 then
        Bar.Size = UDim2.new(1.006, 0,1, 0)
    elseif Thirst.Value <= 80 then
        Bar.Size = UDim2.new(0.8, 0,1, 0)
    elseif Thirst.Value <= 60 then
        Bar.Size = UDim2.new(0.6, 0,1, 0)
    elseif Thirst.Value <= 40 then
        Bar.Size = UDim2.new(0.4, 0,1, 0)
    elseif Thirst.Value <= 20 then
        Bar.Size = UDim2.new(0.2, 0,1, 0)
    elseif Thirst.Value <= 10 then
        Bar.Size = UDim2.new(0.1, 0,1, 0)
    elseif Thirst.Value <= 5 then
        Bar.Size = UDim2.new(0.05, 0,1, 0)
    elseif Thirst.Value <=0 then
        Bar.Size = UDim2.new(0, 0,1, 0)
        script.Parent.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0
    end

end


while true do
wait(.1)
Check()

end

Get Thirstier Script

local Hunger = script.Parent.Parent.Thirst
local Amount = script.Parent.Parent.RateOfLoss
local Time = script.Parent.Parent.Time
while true do
wait(Time.Value)
Hunger.Value = Hunger.Value - Amount.Value
end 

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
8 years ago

UDim2.new requires four arguments. You only gave it three.

Simply put in a fourth argument and it should work;

gui.Size = UDim2.new(0.5, 0, 0.5, 0)

It works like this: UDim2.new(xScale, xOffset, yScale, yOffset)


To clarify if you didn't already know, GUIs use two different methods for size and position: scale and offset.

Scale is a percentage of your screen, while Offset is in pixels.

Scale will cause the GUI to be smaller the smaller your screen is, but if you use offset it will remain the same size on all screens.

Ad

Answer this question