I’ve been wanting to make this gun for a while now but just didn’t know how to make it here is what i’m talking about : Cancelled project
As you can see it supports both first and third person which i think is pretty cool.
Does anyone know how fo i go about making this.
(Any tips would be very appreciated) And thx in advance!
“Please do not ask people to write entire scripts or design entire systems for you.”
I dod not do that i just asked for help and in the parenthesis i just told anyone to write “Some lines of code” just so i can understand more.And i’m sorry if it isn’t what it looks like.
you still have to at least do some work though
Ok i’ll edit what i said and ask for some tips then
thats not what im saying im saying that you have to actually put some work in instead of just coming on and asking for people to make you stuff
I just don’t know where to begin.
You should probably begin with learning how to raycast, since you said you dont really know how to raycast
The major difference between the two systems is how the camera works. First-person cameras are at or close to the same position as the character’s head, while third-person cameras have a relatively larger offset from the head.
The first step would be scripting a basic camera system from scratch. You need to get rid of the built-in camera system, which you can do by creating a LocalScript in StarterPlayerScripts called CameraScript. If you don’t do that, Roblox automatically inserts the default camera controller into each Player.PlayerScripts
when a player joins.
The most basic thing a camera system does is controlling the CFrame of the camera. To do that, you must get a reference to the currently active camera and set its CameraType property to Scriptable. E.g.:
--StarterPlayer.StarterPlayerScripts.CameraScript
local camera = game.Workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(Vector3.new(0, 100, 0), Vector3.new(0, 0, 0))
This makes the camera look down from 100 studs above the origin of the game world.
For 1st and 3rd person camera systems, you want the camera to follow the character in one way or another. To do that, you must repeatedly update the CFrame of the camera to make it keep up with the character.
You can do that by setting up a Connection to the RunService.PreRender event. Any of the other RunService events that update every frame would also work, but AFAIK PreRender is the one to go with for camera systems, because you want the camera’s movement to be the last thing that happens before the scene is rendered. If you get this wrong, your camera might appear to be one frame behind the physics simulation and anything that is affected by other scripts in your game. My knowledge of this is not suuuuper up to date, so if anyone knows a better way please correct me
Anyway, that all looks like so:
local RunS = game:GetService("RunService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharactedAdded:Wait()
local camera = game.Workspace.CurrentCamera
local cameraOffset = CFrame.new(-5, 3, 8) --A bit to the left, a bit up, and quite a bit back
camera.CameraType = Enum.CameraType.Scriptable
RunS.PreRender:Connect(function(dt)
local cameraRootpart = character.Head
if cameraRootpart then
camera.CFrame = cameraRootpart.CFrame * cameraOffset
end
end)
Here cameraOffset
controls how the camera is positioned (and rotated) relative to the head of the character. Since it’s pretty big, it makes it into a 3rd person camera. If you want a 1st person camera you can set it to 0.
Anyway, that’s the basics of how a camera system works. Play around with it and try to get it to work like you want, and feel free to post any questions as they come up
The first step would probably be to make the rotation of the camera independent of the character, because right now the cam can only look in the exact same direction as the character. Most camera systems let the player rotate the camera with mouse movement, swipes on touch screens and thumb stick movement on game pads. You can use UserInputService or ContextActionService to get player input though all input methods (I prefer UserInputService). If you e.g. want to implement mouse camera controls, listen for MouseMovement inputs through the UserInputService.InputChanged event, and rotate the camera based on the X and Y screen-space mouse movement.
https://developer.roblox.com/en-us/api-reference/property/InputObject/UserInputType
Oh thx for the help i’ll make all of the gun system stuff my own and yeah thx again!