I’m currently making a simple fps framework so I will know how to make ones in the future and I have pretty much everything set.
Whenever I have the gun equipped and move too fast or maybe have my mouse do an entire seizure, it just flings me or sends me across the map.
I’ve tried checking that everything has cancollide off and isnt anchored, and that applies to everything currently, all my scripts seem to work fine and have no issues.
Video/gif: https://gyazo.com/1a0cba44ad125b9e7bb31b0c24c49c15
Game: gun test - Roblox
Local script (main controls):
local run = game:GetService('RunService')
local cam = game.Workspace.CurrentCamera
local set = game.ReplicatedStorage:WaitForChild("Arms"):Clone()
local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local ams = set:WaitForChild("Animations")
local mse = plr:GetMouse()
local amo = 10
local chr = plr.Character or plr.CharacterAdded:Wait()
local gui = plr.PlayerGui:WaitForChild("ScreenGui")
local fireDelay = .1
local firing = false
local reloadingDelay = 2.1
local reloading = false
local loaded = false
local hum = chr:WaitForChild("Humanoid")
local empty = hum:LoadAnimation(ams:WaitForChild("GunEmpty"))
set.Parent = cam
run.RenderStepped:Connect(function()
set:SetPrimaryPartCFrame(cam.CFrame*CFrame.new(0,0,0))
end)
local humanoid = set:WaitForChild("Humanoid")
local hold = humanoid:LoadAnimation(ams:WaitForChild("GunHold"))
hold.Looped = true
hold:Play()
mse.Button1Down:Connect(function()
if amo > 1 then
if firing == false and reloading == false and loaded == true then
local humanoid = set:WaitForChild("Humanoid")
local fire = humanoid:LoadAnimation(ams:WaitForChild("GunFire"))
fire:Play()
firing = true
set.Gun.Receiver.Fire:Play()
amo -= 1
gui.Frame.Frame.Current.Text = tonumber(gui.Frame.Frame.Current.Text) - 1
wait(fireDelay)
firing = false
end
elseif amo == 1 then
if firing == false and reloading == false and loaded == true then
local humanoid = set:WaitForChild("Humanoid")
local fire = humanoid:LoadAnimation(ams:WaitForChild("GunLastBulletFire"))
fire:Play()
firing = true
amo -= 1
set.Gun.Receiver.Fire:Play()
gui.Frame.Frame.Current.Text = tonumber(gui.Frame.Frame.Current.Text) - 1
hold.Looped = false
empty.Looped = true
empty:Play()
wait(fireDelay)
firing = false
loaded = false
end
elseif amo == 0 then
set.Gun.Receiver.Empty:Play()
end
end)
uis.InputBegan:Connect(function(input,gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.F then
if loaded == false then
loaded = true
else
amo -= 1
gui.Frame.Frame.Current.Text = tonumber(gui.Frame.Frame.Current.Text) - 1
end
local humanoid = set:WaitForChild("Humanoid")
local inspect = humanoid:LoadAnimation(ams:WaitForChild("GunThingy"))
inspect:Play()
set.Gun.Slide.Back:Play()
set.Gun.Slide.Back.Ended:Wait()
set.Gun.Slide.Forward:Play()
set.Gun.Slide.Forward.Ended:Wait()
elseif input.KeyCode == Enum.KeyCode.R then
local humanoid = set:WaitForChild("Humanoid")
local reload = humanoid:LoadAnimation(ams:WaitForChild("GunReload"))
if reloading == false and amo < 10 then
empty.Looped = false
set.Gun.Receiver.Reload:Play()
reload:Play()
reloading = true
wait(reloadingDelay)
reloading = false
gui.Frame.Frame.Current.Text = 10
amo = 10
end
end
end)