I’ve been trying to make this gun for an hour and I’ve been doing pretty good, but I’ve run into a problem when loading in. I’ve tried looking for the character through WaitForChild and FindFirstChild, I’ve spoken with friends, but I keep getting the same result.
local player = game:GetService("Players").LocalPlayer
local char = player.Character
if not char or not char.Parent then
char = player.CharacterAdded:Wait()
endlocal mouse = player:GetMouse()
local ori = char.Head.Position
local dir = mouse.Hit.p
Each time, it results in saying the head is not a valid member or a silent error where it just doesn’t work.
local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
if char then
local head = char:WaitForChild("Head")
local mouse = plr:GetMouse()
local ori = head.Position
local dir = mouse.Hit.p
end
What is happening as of now is the script is not finding the Head model. Hence it gives the errror “attempt to index nil with position” as head is nil. Having a waitforchild simply waits the current script until the object is found but since it is not being found it is holding the script infnitely. I recommend looking in the players model in workspace and seeing if you are finding the head in the player model.