-
What do you want to achieve?
I am trying to make like a dash system for example Rogue Lineage Dragon Sage Class one just to tell the module.
-
What is the issue?
So I was using @Quasiduck 's Lightning module, I’ve never used it before and I got this problem “ReplicatedStorage.Modules.LightningBolt:88: attempt to perform arithmetic (mul) on nil and number”
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I havent tried any solution yet since how I said its my first time using it and I have no clue what is causing the error.
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local HumRP = char:WaitForChild("HumanoidRootPart")
local DashDis = 20
local Cooldown = 0.5
local camera = workspace.CurrentCamera
local LightningBolt = require(game.ReplicatedStorage.Modules.LightningBolt)
local Debounce = false
local function castRay(caster, rayLength)
local ray = Ray.new(caster.Position, caster.CFrame.LookVector * rayLength)
return workspace:FindPartOnRay(ray, caster.Parent)
end
local function effect(humrppos)
local part1 = char.HumanoidRootPart
local part2 = Instance.new("Part", game.Workspace.FX)
part2.Name = "part2"
part2.Transparency = 1
part2.Position = humrppos
local a1, a2 = Instance.new("Attachment", part1), Instance.new("Attachment", part2)
local Beam = Instance.new("Beam", game.Workspace.FX)
Beam.Enabled = false
Beam.Attachment0 = a1
Beam.Attachment1 = a2
wait(0.01)
while wait() do
Beam.Enabled = true
local ranCF = CFrame.fromAxisAngle((part2.Position - part1.Position).Unit, 2*math.random()*math.pi)
local A1, A2 = {}, {}
A1.WorldPosition, A1.WorldAxis = a1.WorldPosition, ranCF*a1.WorldAxis
A2.WorldPosition, A2.WorldAxis = a2.WorldPosition, ranCF*a2.WorldAxis
local NewBolt = LightningBolt.new(A1, A2, 40)
NewBolt.CurveSize0, NewBolt.CurveSize1 = Beam.CurveSize0, Beam.CurveSize1
NewBolt.PulseSpeed = 2
NewBolt.PulseLength = 0.5
NewBolt.FadeLength = 0.25
NewBolt.Color = Color3.new(0.666667, 0, 1)
local NewSparks = LightningBolt.new(NewBolt)
wait(0.3)
break
end
game.Debris:AddItem(Beam, 0.31)
game.Debris:AddItem(a1, 0.31)
game.Debris:AddItem(a2, 0.31)
game.Debris:AddItem(part2, 0.31)
end
UIS.InputBegan:Connect(function(input, IsTyping)
if IsTyping then return end
if Debounce == true then return end
if input.KeyCode == Enum.KeyCode.Q then
local hitPart, hitPosition = castRay(HumRP, DashDis)
if hitPosition ~= nil then
Debounce = true
local NewCFrame = CFrame.new(hitPosition) * (HumRP.CFrame - HumRP.Position)
char:SetPrimaryPartCFrame(NewCFrame)
effect(char.HumanoidRootPart.Position)
wait(Cooldown)
Debounce = false
elseif hitPosition and hitPart == nil then
Debounce = true
effect(char.HumanoidRootPart.Position)
local NewCFrame = (HumRP.CFrame.LookVector * DashDis) * (HumRP.CFrame - HumRP.Position)
char:SetPrimaryPartCFrame(NewCFrame)
wait(Cooldown)
Debounce = false
end
end
end)
Actually, ignore the post I fixed it, it was a random errow with NewSparks I tried to use LightningBolt.new with the LightningBolt Module