Gun not working

I’ve got a gun that works while testing, but not with other people for some reason. The error comes in the humanoid variable. Anyone able to help?

local tool = script.Parent
local user
local Ignore = {player.Character, tool}--Ignoring the player's character and the tool

local ray = Ray.new(tool.Handle.CFrame.p, (mousePos - tool.Handle.CFrame.p).unit*300)
local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, Ignore)--Putting the table in the ray
local humanoid = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
1 Like

Can we see the error?

This text will be blurred

To add on to @IConsumeCheddar , is it in a localscript or a script?

Another thing to add,

Yeah it has to be both a localscript and script. You need a remoteevent that gets the mouse of the player using the gun and damage the target (if it finds a humanoid) in the script.

Yeah you’re right. Gets the mouse in a local script, then runs it through the server script.

1 Like

Gets the mouse in a local script and passes it onto this server script

Add this to the top of your localscript

game.Players.LocalPlayer.CharacterAdded:Wait()

(and I’m gonna go play games so sorry if I don’t respond)

That just broke the whole gun, doesn’t work at all now.

Can you send the error that roblox is telling you

Gimme a sec, just need to get it

Oh, it’s magically fixed! Strange.

2 Likes