Hello, Im trying to make a function that can be fired from a regular script to a module script so I can keep things more organized.
But Im continuously getting this error…
01:00:20.062 ServerScriptService.Script:8: attempt to call a nil value - Server - Script:8
01:00:20.062 Stack Begin - Studio
01:00:20.062 Script 'ServerScriptService.Script', Line 8 - Studio - Script:8
01:00:20.063 Stack End - Studio
Script
local module = {}
local AttackZones = game.Workspace:WaitForChild("AttackZones")
local zoneL = AttackZones:WaitForChild("LeftZone")
local zoneR = AttackZones:WaitForChild("RightZone")
local zoneL2 = AttackZones:WaitForChild("LowerZone")
local zoneU = AttackZones:WaitForChild("UpperZone")
local sliderAttack = game:GetService("ReplicatedStorage"):WaitForChild("Attacks"):WaitForChild("Slider")
function slider(zone)
if zone == "zoneL" then
local clonedAttack = sliderAttack:Clone()
clonedAttack.Position = zoneL
clonedAttack.Parent = game.Workspace
for i = 1, 51 do
clonedAttack.Transparency += 0.02
clonedAttack.Size += Vector3.new(0,0,1)
end
end
end
return module
You need to make the module script’s function name differently to be seen from the scope you’re accessing.
Try this…
local module = {}
local AttackZones = game.Workspace:WaitForChild("AttackZones")
local zoneL = AttackZones:WaitForChild("LeftZone")
local zoneR = AttackZones:WaitForChild("RightZone")
local zoneL2 = AttackZones:WaitForChild("LowerZone")
local zoneU = AttackZones:WaitForChild("UpperZone")
local sliderAttack = game:GetService("ReplicatedStorage"):WaitForChild("Attacks"):WaitForChild("Slider")
function module.slider(zone)
if zone == "zoneL" then
local clonedAttack = sliderAttack:Clone()
clonedAttack.Position = zoneL
clonedAttack.Parent = game.Workspace
for i = 1, 51 do
clonedAttack.Transparency += 0.02
clonedAttack.Size += Vector3.new(0,0,1)
end
end
end
return module