#greater than symbols not processing properly or something idk

1 messages · Page 1 of 1 (latest)

iron gulch
#
local Music = game:GetService("SoundService")

local Neutral = Music.Neutral
local FirstTrumpet = Music.FirstTrumpet
local SecondTrumpet = Music.SecondTrumpet
local ThirdTrumpet = Music.ThirdTrumpet

local RiskLevel = game.ReplicatedStorage.Variables.TotalRiskLevel.Value
local AbnosBreached = game.ReplicatedStorage.Variables.AbnosBreached.Value --ts will probably go unused honestly

local CurrentTrack = nil

local function ManageMusic()
    if CurrentTrack ~= nil then
        CurrentTrack:Stop()
    end
    if RiskLevel == 0 then
        CurrentTrack = Neutral
    elseif RiskLevel > 1 and RiskLevel < 5 then        
        CurrentTrack = FirstTrumpet
    elseif RiskLevel > 5 and RiskLevel < 10 then
        CurrentTrack = SecondTrumpet
    elseif RiskLevel >= 10 then
        CurrentTrack = ThirdTrumpet
    end
    print(CurrentTrack.Name)
    
    CurrentTrack.Looped = true
    CurrentTrack:Play()
end

ManageMusic()

game.ReplicatedStorage.Variables.TotalRiskLevel.Changed:Connect(ManageMusic)```
#

roblox is ragebaiting me

lone silo
#

So just to make sure, the problem is that the script should be printing FirstTrumpet instead of Neutral when the risk level is equal to 2?

iron gulch
#

ok so I've realized everything mathmatically works fine

lone silo
#

Are you updating the risk level value throughout the game? and is the total risk level default value set to 0?

iron gulch
#

it's just not resetting the track

#

or changing

iron gulch
#

oh wait

#

hold on

#

nope nvm

#

see it's changing

#

it's running the function again

#

but the current track isn't changing

lone silo
#

Then it could be a problem with how you are getting the risk level value, in your script you are setting RiskLevel equal to the value of the TotalRiskLevel object, so you are setting the variable equal to what the value is at that time, not what it is at all times

#

essentially the variable is stuck at 0

iron gulch
#

it shouldn't be, I've verified that the variable is infact changing

lone silo
#

yes but is the variable itself changing

iron gulch
#

oh wait

#

I see

proven veldt
#

Just use studio assisinat to fix the code

lone silo
#

bruh

proven veldt
#

I mean its and idea

lone silo
#

I mean it prob could but ai can be mega unreliable in debugging, plus if someone human knows the exact problem its uneeded

iron gulch
# lone silo bruh
local Music = game:GetService("SoundService")

local Neutral = Music.Neutral
local FirstTrumpet = Music.FirstTrumpet
local SecondTrumpet = Music.SecondTrumpet
local ThirdTrumpet = Music.ThirdTrumpet

local RiskLevel = game.ReplicatedStorage.Variables.TotalRiskLevel
local AbnosBreached = game.ReplicatedStorage.Variables.AbnosBreached --ts will probably go unused honestly

local CurrentTrack = nil

local function ManageMusic()
    if CurrentTrack ~= nil then
        CurrentTrack:Stop()
        local CurrentTrack = nil
    end
    if RiskLevel == 0 then
        CurrentTrack = Neutral
    elseif RiskLevel.Value > 1 and RiskLevel.Value < 5 then        
        CurrentTrack = FirstTrumpet
    elseif RiskLevel.Value > 5 and RiskLevel.Value < 10 then
        CurrentTrack = SecondTrumpet
    elseif RiskLevel.Value >= 10 then
        CurrentTrack = ThirdTrumpet
    end
    print(CurrentTrack.Name)
    
    CurrentTrack.Looped = true
    CurrentTrack:Play()
end

ManageMusic()

game.ReplicatedStorage.Variables.TotalRiskLevel.Changed:Connect(ManageMusic)```
#

this works

proven veldt
#

He could try

iron gulch
#

the local variable was always set to a constant value like you said

lone silo
#

Nice, but one more thing

#

Is your risk value ever 1 or 5, im worried your script doesnt account for those values

proven veldt
#

btw guys is there a animation plugin like moon animator but for free?

lone silo
#

for example you are checking if the value is 0, or greater than 1, but never if its 1 istself

iron gulch
#

oh right hold on I forgot to fix that

proven veldt
#

Im good at Animations but roblox animation editor sucks

iron gulch
#

ok yeah this should work

lone silo