Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Could someone help me with "The First Person Element Of A First Person Shooter" blog?

So I am trying to make an FPS game using "The First Person Element Of A First Person Shooter" blog, but I am having trouble on the first step of making the gun appear in front of the camera.

--LocalScript in StarterPack

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local rsStorage = game:GetService("ReplicatedStorage")

local camera = game.Workspace.CurrentCamera
local humanoid = player.CharacterAdded:Wait():WaitForChild("Humanoid")

local viewModel = rsStorage:WaitForChild("viewModel"):Clone()

local function onDied()
	viewModel.Parent = nil
end

local function onUpdate(dt)
	viewModel.Head.CFrame = camera.CFrame
	print("hi")
end

humanoid.Died:Connect(onDied)
game:GetService("RunService").RenderStepped:Connect(onUpdate)

local repWeapon = rsStorage:WaitForChild("FAMAS")
local weapon = repWeapon:Clone()

weapon.Parent = viewModel
viewModel.Parent = camera

local joint = Instance.new("Motor6D")
joint.C0 = CFrame.new(1, 1, 1)
joint.Part0 = viewModel.Head
joint.Part1 = weapon.Handle
joint.Parent = viewModel.Head
print("Done")

It prints "Done" and keeps printing "hi". There are no errors in the output. Also, sorry that the script is kind of long. Another thing is that I can see the viewModel and the FAMAS in random positions in the workspace.

1 answer

Put the camera max zoom distance value to as low as it goes, start making the player shoot and win!

I understand your frustration in getting to work a semi-auto hand pistol shooter. Tough hurdles are going to come your way and now you can do something:

Yes I did read it and it seems you're trying to make your guns go in front of your camera in 1st Person perspective and make it greet you or something along the lines of realistic interactive communication with an object such as a Desert Eagle.

I'm your friend believe it, or not and I'm working by your side every step of the journey...

2 comments

0

Did you even read it...

0

Screenshot what it looks like when youf are in First-Person mode ASAP...

This discussion is preserved as it was. New answers, comments, and votes are closed.