The error is on Line 16. "Attempt to index local 'player' (a nil value)" How would I define the player from a regular function. I tried putting the player in as a parameter but it didn't work.
Script in ServerScriptService Error on Line 16
leds = {}
function fade()
for i, v in pairs(leds) do
if v~= nil then
v.Transparency = v.Transparency + 0.2
if v.Transparency > 1 then
v:Destroy()
end
end
end
end
function makelig(player)
local b = player.Character:GetChildren()
for i = 1, #b do
if b[i].Name == "Left Arm" or b[i].Name == "Left Leg" or b[i].Name == "Right Arm" or b[i].Name == "Right Leg" then
local tip = b[i]
local lastpoint = b[i].Position
local tool = b[i]
if tip~= nil then
local off = tip.Size.z/2
local point = (tip.CFrame*CFrame.new(0, 0, -off)).p
local unit = (lastpoint - point).unit
local mag = (lastpoint - point).magnitude
if tool.Parent.Humanoid.WalkSpeed > 55 and mag>10 then
local middle = lastpoint-(unit*(mag/2))
local cf = CFrame.new(middle, point)
local l = Instance.new("Part")
l.Shape = tip.Shape
l.Name = "lightning"
l.Anchored = true
l.CanCollide = false
l.Size = Vector3.new(0.2, 0.2, mag)
l.BrickColor = BrickColor.new("Curry")
l.Reflectance = tip.Reflectance
l.Material = "Neon"
l.TopSurface = 0
l.Transparency = 0
l.BottomSurface = 0
l.Parent = tip
l.CFrame = cf
table.insert(leds, l)
lastpoint = point
end
end
end
end
end
game.ReplicatedStorage.Lightning.OnServerEvent:Connect(function(player)
game:GetService("StarterGui").ControlHUD.Frame.Plus.Lightning.Control:Clone().Parent = player.PlayerGui
--player.PlayerGui:WaitForChild("ControlHUD").Frame.Plus.Lightning.Control:Clone().Parent = player.PlayerGui
while true do
makelig()
wait()
fade()
wait()
end
end)
LocalScript in TextButton
script.Parent.MouseButton1Down:Connect(function()
game.ReplicatedStorage.Lightning:FireServer()
end)

1 comment
On line 60 of the script you did not give it a player, makelig(player)