I'm currently making a game, and can't seem to figure out what is wrong with my script. The only thing showing up in output is something about line 26, but it isn't an error. Does anybody know to make it so it actually attaches to the camera instead of staying on the floor?
Here is the script:
repeat
wait()
until game:IsLoaded()
local plr = game.Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()
local cam = workspace.CurrentCamera
local Run = game:GetService("RunService")
local RS = game.ReplicatedStorage
local GunModules = RS:WaitForChild("GunModules")
local GunModels = RS:WaitForChild("GunModels")
local Primary = "Assault Rifle"
local WeaponInHand
local WeaponData
local maincf = CFrame.new() --weapon offset of camera
plr.CameraMode = Enum.CameraMode.LockFirstPerson
Run.RenderStepped:Connect(function()
if WeaponInHand then
WeaponInHand:SetPrimaryPartCframe(
cam.CFrame
* maincf
)
end
end)
function setup(weapon)
WeaponData = require(GunModules:WaitForChild("Assault Rifle"))
maincf = WeaponData.MainCFrame
WeaponInHand = GunModels:WaitForChild(weapon)
WeaponInHand.PrimaryPart = WeaponInHand:WaitForChild("Handle")
WeaponInHand.Parent = cam
for i, part in pairs(WeaponInHand:GetChildren()) do
if part:IsA("BasePart") then
part.Anchored = true
part.CanColide = false
end
end
end
setup(Primary)

2 comments
what error are you getting? just because you dont understand it it doesnt mean it's not an error
It says 'Script 'Players.NuggetHasJoined.PlayerGui.LocalScript', Line 26'