So I made a gun but It doesn’t look to good because it doesn’t even have good effects like if the player shoots the camera doesn’t shake. Is there a module I can use that’s simple? I don’t know much about modules that’s why Im trying to find a simple one. Any help? Thanks
You can set the camera’s rotation when it’s used. Something like this:
local camera = game.Workspace.Camera
local RunService = game:GetService("RunService")
camera.CameraType = Enum.CameraType.Scriptable
RunService.RenderStepped:Connect(function()
-- whenever the gun shoots
camera.CFrame *= CFrame.Angles(math.rad(15), 0, 0) --you'll need to play with this value
delay(.1, function()
camera.CFrame *= CFrame.Angles(0,0,0)
end)
end)
This was pseudo-coded so I don’t know if it 100% works
wouldnt I need to get CurrentCamera instead of camera?
No, you can use the camera since this is all in a local script and isn’t replicated for everyone.
My gun has the function:
function Fire(direction)
Can I remove the Runservice and use the rest of the script inside the function?
It would probably be recommended to get the current camera since 1. it is a read only property 2. it is guaranteed to point to the camera of the player and not some other instance that may be named Camera
Well I tried defining it as CurrentCamera but it doesnt do the camera shake.
RunService is best as it is a lot more accurate.
Yeah but I don’t know how to put it to my gun?
You can use the .Activated like this:
local connection
Gun.Activated:Connect(function()
connection = RunService.RenderStepped:Connect(function()
end)
end)
And when the gun is Unequipped, just do connection:Disconnect()
Thing is the server script of my gun doesnt use tool.Activated
This would need to be done on the Client side in a local script.
But how would I detect if the gun even shoots?
You can fire a RemoteEvent from the client and have it be received by the server.
wouldnt it have to be the opposite? server script to the client script?
Oh right, yes sorry. It’s a bit late for me haha! But yes, you can detect t that way, do the camera rotations.