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

9 comments

0

The mouse does not exist on the server. Don't send the mouse, simply send the Hit

0

where wich line shall I put it?

0

Instead of sending the mouse you'd send the Hit in place of the mouse. Though you'll need to rewrite a few lines so it works

0

you mean mouse.hit ?

1

Yes, and Mouse.hit is actually deprecated, so you want to send Mouse.Hit

0

so on line 16 in the local script, in the brackets between "FireServer()" write Mouse.hit ?

0

yes

0

then when i fire the Server in the original script , in THOES brackets put the Paramater Mouse.hit as well? so im gussing you CAN Actually carry things to other Script!? thats cool! :D

0

wwait on line 14 it erros with a red line when i put "plr,mouse.hit" in bettween the brackets,.Should i just put Mousehit instead?