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

My speed only changes once despite meeting appropriate conditions?

Asked by
net_h 13
4 years ago
local PAGE = script.Parent.Parent
local PlayerAge = PAGE.AccountAge
local PlayerName = PAGE.Name
local Character = PAGE.Character or PAGE.CharacterAdded:Wait()
local PSPEED = Character:WaitForChild("Humanoid")
local ageInMonths = math.floor((PlayerAge * 100) / 30) / 100
local ageInYears = math.floor((PlayerAge * 100) / 365) / 100

game.StarterGui:SetCore("ChatMakeSystemMessage",{Text = "Welcome "..PlayerName.." Your account age is "..PlayerAge.." days old",Color = Color3.new(0,196,255),Font = Enum.Font.ArialBold,FontSize = Enum.FontSize.Size32})
if PlayerAge < 30 then
    game.game.StarterGui:SetCore("ChatMakeSystemMessage",{Text = "Which isn't even a month. ",Color = Color3.new(0,196,255),Font = Enum.Font.ArialBold,FontSize = Enum.FontSize.Size32})
    else
end
if PlayerAge < 365 then
    game.StarterGui:SetCore("ChatMakeSystemMessage",{Text = "Which isn't even a year, But it is however "..ageInMonths.." months old.",Color = Color3.new(0,196,255),Font = Enum.Font.ArialBold,FontSize = Enum.FontSize.Size32})
    elseif 
    PlayerAge > 365 then
    game.StarterGui:SetCore("ChatMakeSystemMessage",{Text = "Which is "..ageInMonths.." in months".." or "..ageInYears.." in years",Color = Color3.new(0,196,255),Font = Enum.Font.ArialBold,FontSize = Enum.FontSize.Size32})
end

-- speed
if PlayerAge > 10 then
    PSPEED.WalkSpeed = 12
elseif PlayerAge > 20 then
        PSPEED.WalkSpeed = 15
        elseif
PlayerAge > 50 then
            PSPEED.WalkSpeed = 22
elseif PlayerAge > 100 then
                PSPEED.WalkSpeed = 27
elseif PlayerAge > 200 then
                    PSPEED.WalkSpeed = 35
elseif PlayerAge > 350 then
                        PSPEED.WalkSpeed = 42
elseif PlayerAge > 500 then
        PSPEED.WalkSpeed = 50
elseif PlayerAge > 750 then
            PSPEED.WalkSpeed = 60
elseif PlayerAge > 1000 then
                PSPEED.WalkSpeed = 70
end

the only really relevant part is the '--speed-' part my account age is 500 yet it only sets my walk speed to 10 and not the appropriate 50, what wrong?

1 answer

Log in to vote
0
Answered by
net_h 13
4 years ago

SOLVED IT: reversed the numbers like this thanks to a guy on discord

if PlayerAge > 1000 then
    PSPEED.WalkSpeed = 70
elseif PlayerAge > 750 then
    PSPEED.WalkSpeed = 60
elseif PlayerAge > 500 then
    PSPEED.WalkSpeed = 50
elseif PlayerAge > 350 then
    PSPEED.WalkSpeed = 42
elseif PlayerAge > 200 then
    PSPEED.WalkSpeed = 35
elseif PlayerAge > 100 then
    PSPEED.WalkSpeed = 27
elseif PlayerAge > 50 then
    PSPEED.WalkSpeed = 22
elseif PlayerAge > 20 then
    PSPEED.WalkSpeed = 15
elseif PlayerAge > 10 then
    PSPEED.WalkSpeed = 12
end
Ad

Answer this question