Error I'd assume is either transferring the hit position or, line 60, but it doesn't output anything.
Same LocalScript Code:
local Tool = script.Parent local vExit = Tool:WaitForChild("Exit") local Player = game:GetService("Players").LocalPlayer local PointEvent = Instance.new("RemoteEvent") PointEvent.Parent = script.Parent PointEvent.Name = "PointEvent" ------------------------------------------------ function Equip(Mouse) Wielder = Tool.Parent workspacechar = Wielder.Name local Humanoid = Wielder:FindFirstChild("Humanoid") local HoldA = Tool:WaitForChild("Idle") if Humanoid and Humanoid.Health >= 1 then Hold = Humanoid:LoadAnimation(HoldA) Hold:Play() end --[[ if Mouse == nil then Player:GetMouse() else return end]] Mouse.Button1Down:connect(function() PointEvent:FireServer(Mouse.Hit.p) end) end ------------------------------------------------ function Unequip() if Hold then Hold:Stop() end end ------------------------------------------ --------------------------------------- Tool.Equipped:connect(Equip)
New Script Code:
local Tool = script.Parent local vExit = Tool:WaitForChild("Exit") local Config = Tool:WaitForChild("Configuration") local PointEvent = Tool:WaitForChild("PointEvent") ------------------------------------------------ function Equip() Wielder = Tool.Parent workspacechar = Wielder.Name local Humanoid = Wielder:FindFirstChild("Humanoid") local Player = game.Players:FindFirstChild(workspacechar) FireS = Tool.Handle:WaitForChild("Fire") Pump = Tool.Handle:WaitForChild("Pump") Mouse = Player:GetMouse() end ------------------------------------------------ function Unequip() if FireS then FireS:Stop() end if Pump then Pump:Stop() end end ------------------------------------------ function Reload() Tool.Enabled = false for i = 1, 7 do Config.Ammo.Value = Config.Ammo.Value + 1 Pump:Play() wait(FireS.TimeLength) end Tool.Enabled = true end ----------------------------------------- function Fire() PointEvent.OnServerEvent:connect(function(player, hit) target = hit print(hit) end) wait() if Tool.Enabled == false then return end if Config.Ammo.Value <= 0 then Reload() return end if FireS then FireS:Play() end Config.Ammo.Value = Config.Ammo.Value - 1 Tool.Enabled = false for i = 1, math.random(7,10) do --number of bullets coming out local ray = Ray.new(Tool.Exit.Position, ((target - Vector3.new(math.random(-0.25, 1), math.random(-1,2), math.random(-0.25, 1)) - Tool.Exit.Position)).unit * 45) local part, position = workspace:FindPartOnRay(ray, game.Workspace:FindFirstChild(workspacechar), false, true) local beam = Instance.new("Part", workspace) beam.BrickColor = BrickColor.new("Medium stone grey") beam.FormFactor = "Custom" beam.Material = "Plastic" beam.Transparency = 0.915 beam.Anchored = true beam.Locked = true beam.CanCollide = false local distance = (Tool.Exit.CFrame.p - position).magnitude beam.Size = Vector3.new(0.05, 0.05, distance) beam.CFrame = CFrame.new(Tool.Exit.CFrame.p, position) * CFrame.new(Tool.Exit.Position,Tool.Exit.CFrame.p, -distance / 2) game:GetService("Debris"):AddItem(beam, 0.1) if part then local humanoid = part.Parent:FindFirstChild("Humanoid") if not humanoid then humanoid = part.Parent.Parent:FindFirstChild("Humanoid") end if humanoid then humanoid:TakeDamage(math.random(5.5,7)) end end end wait(.565) Tool.Enabled = true end --end --------------------------------------- Tool.Equipped:connect(Equip) Tool.Unequipped:connect(Unequip) Tool.Activated:connect(Fire)
EDIT: I have fixed this online but, upon joining the game it doesn't fire, nor does it make any errors, why is that now?
When you FireServer
, you don't need to specify the player, that is sent automatically as the first argument for the OnServerEvent.
Also when you fire the information, you only send the position (disregarding the player), yet in the event, you have specified a third argument, which would be nil as it's not being sent.