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

Why is it saying my function is a nil value?

Asked by 5 years ago
Edited 5 years ago

https://gyazo.com/aa77efeae669f9139d1fa7fa4f2ef3fa


local raidvalues = game.ReplicatedStorage.RaidValues while true do wait(1) if raidvalues.Value == true then if raidvalues.RaidType.Value == "Domination" then if raidvalues.DefenderPoints.Value >= 3000 then GlobalNotify("Defenders win!") raidvalues.Value = false game.ReplicatedStorage.EndingRaid:FireAllClients() end if raidvalues.RaiderPoints.Value >= 100 then GlobalNotify("Raiders win!") raidvalues.Value = false game.ReplicatedStorage.EndingRaid:FireAllClients() end end end end function GlobalNotify(Notification) game.ReplicatedStorage.RaidNotifications:FireAllClients(Notification) end

All of my values are correct, its just the function does not work.

0
Lava_Scripter provided the correct code, but didn't tell you why he modified it in the way he did. A script runs from top to bottom. If a script is in a while loop forever, it won't reach the lines that are underneath it, because it's repeating what's in the while loop over and over, and will never continue on with the script beyond the while loop. You have to define a function before you call it. Unhumanly 152 — 5y

1 answer

Log in to vote
-1
Answered by 5 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
local raidvalues = game.ReplicatedStorage.RaidValues

function GlobalNotify(Notification)
    game.ReplicatedStorage.RaidNotifications:FireAllClients(Notification)
end

while true do
    wait(1)
    if raidvalues.Value == true then 
        if raidvalues.RaidType.Value == "Domination" then 
            if raidvalues.DefenderPoints.Value >= 3000 then 
                GlobalNotify("Defenders win!")
                raidvalues.Value = false
                game.ReplicatedStorage.EndingRaid:FireAllClients()
            end
            if raidvalues.RaiderPoints.Value >= 100 then 
                GlobalNotify("Raiders win!")
                raidvalues.Value = false
                game.ReplicatedStorage.EndingRaid:FireAllClients()
            end
        end
    end
end
Ad

Answer this question