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

Workspace.GoKart.REV_FE_Sounds.Handler:44: attempt to call field '?' (a nil value) WHY?

Asked by 5 years ago
Edited 5 years ago
local car = script.Parent.Parent
local Sounds = {}
local F = {}

F.newSound = function(name,par,id,pitch,loop)
    for i,v in pairs(Sounds) do
        if i==name then
            v:Stop()
            v:Destroy()
        end
    end

    local sn = Instance.new("Sound",par)

    sn.Name = name
    sn.SoundId = id
    sn.Pitch = pitch
    sn.Looped = loop
    sn.AncestryChanged:connect(function(child,parent) print(parent) end)
    Sounds[name]=sn
end

F.updateSound = function(sound,id,pit,vol)
    local sn = Sounds[sound]
    if id~=sn.SoundId then sn.SoundId = id end
    if pit~=sn.Pitch then sn.Pitch = pit end
end

F.pauseSound = function(sound)
    Sounds[sound]:Pause()
end

F.stopSound = function(sound)
    Sounds[sound]:Stop()
end

F.removeSound = function(sound)
    Sounds[sound]:Stop()
    Sounds[sound]:Destroy()
    Sounds[sound]=nil
end

script.Parent.OnServerEvent:connect(function(pl,Fnc,...)
    F[Fnc](...)
end)

wait(0.1)

car.DriveSeat.ChildRemoved:connect(function(child)
    if child.Name=="SeatWeld" then
        F.removeSound("Rev")
    end
end)

My other scripts are set out like this too but they work, but this does not ;/

0
the "Fnc" variable listed on line 44 might be a nil value. SmartNode 383 — 5y
0
So what do i do? aleandroblingo -35 — 5y

Answer this question