I'm trying to send information from the client to a module script located in the ReplicatedStorage
and it is working fine on the client side but not the server side why? I want the modulescript create a laser where the mouse is pointing
Here is the module script:
local module = {} local Tomb = { TombOfPermafrost = function(player, power, mouse) local char = player.Character local primaryColor = Color3.fromRGB(91, 176, 255) local mousePos = mouse.hit.p local startPos = char.RightHand.Position if power <= 50 then local shard = Instance.new("Part", Ignore) shard.Color = primaryColor shard.Size = Vector3.new(.2, .2, .2) shard.Anchored = true shard.CanCollide = false shard.Material = Enum.Material.DiamondPlate shard.Reflectance = .5 local ray = Ray.new(startPos, (mousePos - startPos).unit * 100) local target, pos = workspace:FindPartOnRayWithIgnoreList(ray, {player.Character, Ignore}) shard.CFrame = CFrame.new(pos) local pulse = Instance.new("Part", Ignore) pulse.Size = Vector3.new(1,1,1) pulse.Anchored = true pulse.CanCollide = false pulse.CFrame = CFrame.new(startPos, pos) pulse.Color = primaryColor local mesh = ringMesh(pulse) spawn(function() for i = .1, 1, .1 do local size = i * 10 mesh.Scale = Vector3.new(size, size, 1) pulse.Transparency = i pulse.Color = primaryColor:lerp(Color3.fromRGB(200, 200, 200), i) wait() end pulse:Destroy() end) local partRay = Instance.new("Part", Ignore) partRay.Color = primaryColor partRay.Transparency = .5 partRay.Material = Enum.Material.Neon partRay.Anchored = true partRay.CanCollide = false partRay.Size = Vector3.new(.25, .25, (mousePos - startPos).magnitude) partRay.CFrame = CFrame.new(((startPos + mousePos)/2) + 1 * (mousePos - startPos).unit, mousePos) damagePart(target, power * .35, player) Debris:AddItem(partRay, .25) Debris:AddItem(shard, 1) elseif power > 50 and power < 99 then local crystal = Instance.new("Part", Ignore) crystal.Color = primaryColor crystal.Size = Vector3.new(1, 1, 1) crystal.CanCollide = false crystal.CanCollide = false crystal.Material = Enum.Material.SmoothPlastic crystal.Reflectance = 1 crystal.Position = startPos local cryMesh = Instance.new("SpecialMesh", crystal) cryMesh.MeshId = "http://www.roblox.com/Asset/?id=9756362" local blank = blankPart() blank.CFrame = CFrame.new(mousePos) local body = Instance.new("RocketPropulsion", crystal) body.Target = blank body.MaxSpeed = 150 body:Fire() playSound(crystal, "545192890") body.ReachedTarget:connect(function() local crystalCFrame = crystal.CFrame crystal:Destroy() local blue = Color3.fromRGB(91, 176, 255) local sphere = Instance.new("Part", Ignore) sphere.Size = Vector3.new(1, 1, 1) sphere.Anchored = true sphere.CanCollide = false sphere.Color = blue sphere.CFrame = crystalCFrame sphere.TopSurface = Enum.SurfaceType.SmoothNoOutlines sphere.BottomSurface = Enum.SurfaceType.SmoothNoOutlines local mesh = Instance.new("SpecialMesh", sphere) mesh.MeshType = Enum.MeshType.Sphere aceDamage(crystal.Position, 10, power * .35, player) local pulse = Instance.new("Part", Ignore) pulse.Size = Vector3.new(1,1,1) pulse.Anchored = true pulse.CanCollide = false pulse.CFrame = CFrame.new(crystal.Position) * CFrame.Angles(math.pi /2,0,0) pulse.Color = blue local ringMesh = ringMesh(pulse) for i = .1, 1, .1 do local size = 5 + (i * 20) local rSize = size * 2 mesh.Scale = Vector3.new(size, size, size) ringMesh.Scale = Vector3.new(rSize, rSize, 10) wait() end for i = .1, 1, .1 do local size = 25 + (i * 2) mesh.Scale = Vector3.new(size, size, size) pulse.CFrame = pulse.CFrame + Vector3.new(0, .25, 0) pulse.Color = blue:lerp(Color3.fromRGB(200, 200, 200), i) sphere.Color = blue:lerp(Color3.fromRGB(200, 200, 200), i) wait(.25) end for i = .1, 1, .1 do local size = 10 + (i * 2) pulse.Transparency = i sphere.Transparency = i wait() end pulse:Destroy() sphere:Destroy() end) else local laser = Instance.new("Part", Ignore) laser.Color = primaryColor laser.Material = Enum.Material.Neon laser.CanCollide = false laser.TopSurface = Enum.SurfaceType.SmoothNoOutlines laser.BottomSurface = Enum.SurfaceType.SmoothNoOutlines laser.Size = Vector3.new(0.2, 0.2, 1) laser.Position = startPos playSound(laser, "215270668") local startCFrame = mouse.hit.p wait(.2) local endCFrame = func:InvokeClient(player, "Mouse").hit.p for i = .1, 1, .1 do startPos = char.RightHand.Position local ray = Ray.new(startPos, (startCFrame:lerp(endCFrame, i) - startPos).unit * 150) local target, pos = workspace:FindPartOnRayWithIgnoreList(ray, {player.Character, Ignore}) damagePart(target, 30, player) laser.Size = Vector3.new(1, 1, (pos - startPos).magnitude) laser.CFrame = CFrame.new(((startPos + pos)/2) + 1 * (pos - startPos).unit, pos) local ice = Instance.new("Part", Ignore) ice.Color = primaryColor ice.Size = Vector3.new(3, 3, 3) ice.CFrame = CFrame.new(pos) * CFrame.Angles(math.random(1, 3), math.random(1, 3), math.random(1, 3)) ice.Material = Enum.Material.Ice ice.Transparency = .2 ice.Anchored = true ice.CanCollide = false Debris:AddItem(ice, 10) wait() end laser:Destroy() end end } module.ActivateSpell = function(player, ...) local args = {...} local power = args[2] local mainHand = args[1] local mouse = args[3] Tomb[mainHand](player, power, mouse) end return module
Client side: local script
--This client side if working fine by calling it to the module script but it is still giving me a error local player = game.Players.LocalPlayer local char = player.Character local mouse = player:GetMouse() local camera = workspace.CurrentCamera UserInput.InputEnded:connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 and charging then charging = false chargeBar.Visible = false remote:FireServer("ActivateSpell", playerData.MainHand, chargePower, mouse) chargePower = 0 end end)
Error:
05:26:19.015 - ReplicatedStorage.MainModule:179: attempt to index local 'mouse' (a nil value) 05:26:19.016 - Stack Begin 05:26:19.017 - Script 'ReplicatedStorage.MainModule', Line 179 - field ? 05:26:19.017 - Script 'ReplicatedStorage.MainModule', Line 355 - field ? 05:26:19.018 - Script 'ServerScriptService.script', Line 8 05:26:19.018 - Stack End