here is the gun script that im making
-no raycasting, just a projectile
Here is the local script that's fires when Clicked
local mouse = game.Players.LocalPlayer:GetMouse() local tool = script.Parent.Parent local remote = tool.Remotes.shootevent local use = false local cooldown = .5 local play = game.Players.LocalPlayer tool.Activated:Connect(function() ---plocal animation = play.Character.Humanoid:LoadAnimation(tool.Animations.Animation) if use == false then use = true ---animation:Play() wait(.5) ----animation:Stop() print("Slash") remote:FireServer(mouse) wait(cooldown) use = false end end)
and now the script that is supposed to get the bullet and shoot it at mouse direction (A script to shoot the gun when the event is fired)
local tool = script.Parent.Parent local remote = tool.Remotes.shootevent local hand = tool.Handle local hit = false ---////--[Variables]--///------------------------- local config = tool.Configuration local ammo = config.Ammo local Maxammo = config.MaxAmmo local Animations = tool.Animations remote.OnServerEvent:Connect(function(plr,mouse) local char = plr.Character or plr.CharacterAdded:wait() ----------=plr.Data:WaitForChild("Devilf").Value = "MaguFruit" local function GetBullet() local p = config.Bullet:Clone() return p end local mh = mouse.hit local bullet = GetBullet() bullet.CFrame = script.Parent.Handle.CFrame * CFrame.new(char.HumanoidRootPart.CFrame.lookVector * 3) bullet.CFrame = CFrame.new(bullet.Position, mh.p) bullet.BodyVelocity.Velocity = bullet.CFrame.LookVector * 120 bullet.Touched:Connect(function(hit) if hit and hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid:TakeDamage() end end) end)
But for some reason when I clicked it sait "Attemped to index "Mouse as a Nil Value"... Why!? plz help me...
--T40