Attack with a module script not working as it should
ServerScriptService.ATTACKS.UpdatedAttackScript:39: attempt to call a nil value
UpdatedAttackScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EventFolder = ReplicatedStorage:WaitForChild("EVENTS")
local AttackOne = EventFolder:WaitForChild("AttackOne")
local AttackModules = script.AttackModules
function DoModule(Player)
local DataFolder = Player.Data
local Grimoire = DataFolder.Grimoire
local GrimoireName = Grimoire.Value
if GrimoireName == "None" then
warn("Player does not have a Grimoire")
else
local AttackModule = require(AttackModules:WaitForChild(GrimoireName))
AttackModule.AttackOne(Player)
end
end
AttackOne.OnServerEvent:Connect(function(Player)
DoModule(Player)
The Module
local Debris = game:GetService("Debris")
local AttackModule = {}
function AttackOne(Player)
Player.Character.Humanoid.WalkSpeed = 0
Player.Character.Humanoid.JumpPower = 0
wait(.5)
warn("Event Recieved")
local MeshOne = script.BallOne:Clone()
local MeshTwo = script.BallTwo:Clone()
local MeshThree = script.BallThree:Clone()
local MeshFour = script.Wave:Clone()
local Hurmp = Player.Character.HumanoidRootPart
local SFX = script.Sound:Clone()
SFX.Parent = workspace
SFX:Play()
MeshOne.CFrame = Hurmp.CFrame
MeshTwo.CFrame = Hurmp.CFrame
MeshThree.CFrame = Hurmp.CFrame
MeshFour.CFrame = Hurmp.CFrame + Vector3.new(0,-2,0)
MeshOne.Parent = workspace.Debris
MeshTwo.Parent = workspace.Debris
MeshThree.Parent = workspace.Debris
MeshFour.Parent = workspace.Debris
for i = 1,50 do
wait(.005)
MeshOne.Size = MeshOne.Size + Vector3.new(.1,.1,.1)
MeshTwo.Size = MeshTwo.Size + Vector3.new(.1,.1,.1)
MeshThree.Size = MeshThree.Size + Vector3.new(.1,.1,.1)
MeshFour.Size = MeshFour.Size + Vector3.new(.1,0,.1)
end
Player.Character.Humanoid.WalkSpeed = 16
Player.Character.Humanoid.JumpPower = 50
Debris:AddItem(SFX)
Debris:AddItem(MeshOne,.1)
Debris:AddItem(MeshTwo,.1)
Debris:AddItem(MeshThree,.1)
Debris:AddItem(MeshFour,.1)
end
return AttackModule
