I click any part, and it doesn't print it right. Can anyone help me with this? Server Script:

local remotes = game.ReplicatedStorage:WaitForChild("KITRemotes")
local serverremotes = remotes:WaitForChild("Server")
local clientremotes = remotes:WaitForChild("Client")

serverremotes.ShootEvent.OnServerEvent:Connect(function(plr,tool,mousePos,barrelPos)
	if tool:FindFirstChild("shootSound") then
		tool.shootSound.Looped = false
		tool.shootSound:Play()
	else
		print("(AIN GUN KIT) Shoot sound is not found.")
	end
	local ray = Ray.new(mousePos, (mousePos - barrelPos).unit * ((mousePos - barrelPos).magnitude))
	local part,pos = workspace:FindPartOnRay(ray,plr.Character)
	local dist = (mousePos - pos).Magnitude
	print("(AIN GUN KIT) Distance between barrel and mouse: " .. tostring(dist))
	local cloned = game.ReplicatedStorage.shell:Clone()
	cloned.Parent = workspace
	cloned.CFrame = tool.Barrel.CFrame
	cloned.Anchored = false
	local cor = coroutine.wrap(function() wait(3) cloned:Destroy() coroutine.yield("Done") end)()
	if part then
		print("(AIN GUN KIT)",part.Name)
	else
		print("(AIN GUN KIT) Part not found?")
	end
end)

Tool Script:

local tool = script.Parent
local plr = game.Players.LocalPlayer
local remotes = game.ReplicatedStorage:WaitForChild("KITRemotes")
local serverremotes = remotes:WaitForChild("Server")
local clientremotes = remotes:WaitForChild("Client")
tool.Equipped:Connect(function(mouse)
	mouse.Button1Down:Connect(function()
		serverremotes.ShootEvent:FireServer(tool,mouse.Hit.p, tool.Barrel.CFrame.p)
	end)
end)

1 comment

0

Are you referring to any one line?