I’ve been making a ULTRAKILL-inspired roguelike shooter recently.
Theres been this very weird glitch with my gun system.
Whenever I’m in the air and moving backwards with a gun equipped, my character kinda just starts moving to the side, left or right, and sometimes it just starts vibrating left to right.
I can’t really explain it so here’s a video.
robloxapp-20241024-1436057.wmv (5.2 MB)
Here are the scripts incase needed sorry if its messy I’m working on cleaning them up.
Server Script:
local Workspace = game:GetService("Workspace")
local ServerStorage = game:GetService("ServerStorage")
local TweenService = game:GetService("TweenService")
local SoundService = game:GetService("SoundService")
local tool = script.Parent
local shootp = tool:WaitForChild("ShootPart")
local shoot_part = tool:WaitForChild("ShootPart")
local shootremote = tool:WaitForChild("ShootEvent")
local reloadremote = tool:WaitForChild("ReloadEvent")
local fireSound = tool.HoldPart:WaitForChild("Fire")
local reloadSound = tool.HoldPart:WaitForChild("Reload")
local dmg = tool:GetAttribute("Damage")
local headdmg = (dmg * 2.5)
local metaldmg = (dmg / 4)
local maxammo = tool:GetAttribute("MaxAmmo")
local ammo = tool:FindFirstChild("Ammo")
ammo.Value = maxammo
local mags = tool:FindFirstChild("Mags")
shootremote.OnServerEvent:Connect(function(player, position)
local origin = shootp.Position
local direction = (position - origin).Unit*300
local params = RaycastParams.new
local result = Workspace:Raycast(origin, direction)
local intersection = result and result.Position or origin + direction
local distance = (origin - intersection).Magnitude
local bullet_clone = ServerStorage.Bullet:Clone()
bullet_clone.Size = Vector3.new(0.1, 0.1, distance)
bullet_clone.CFrame = CFrame.new(origin, intersection)*CFrame.new(0, 0, -distance/2)
bullet_clone.Parent = Workspace.BulletFolder
bullet_clone.CanCollide = false
bullet_clone.CanQuery = false
local tween = TweenService:Create(bullet_clone, TweenInfo.new(0.5), {Transparency = 1})
fireSound:Play()
ammo.Value -= 1
if result then
local part = result.Instance
local humanoid = part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(dmg)
if part.Name == "Head" then
humanoid:TakeDamage(dmg * 1.5)
if part:FindFirstChild("WEAKCHECK") then
humanoid:TakeDamage(dmg * 1.5)
if part:FindFirstChild("ARMCHECK") then
humanoid:TakeDamage(dmg / 3)
if part:FindFirstChild("SHLDCHECK") then
humanoid:TakeDamage(0)
end
end
end
end
else
if part.Material == Enum.Material.Glass and part:FindFirstChild("Breakable") then
part:Destroy()
end
end
end
tween:Play()
task.wait(0.4)
bullet_clone:Destroy()
end)
reloadremote.OnServerEvent:Connect(function()
if ammo.Value < maxammo then
reloadSound:Play()
ammo.Value = maxammo
end
end)
Local Script
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local tool = script.Parent
local shootremote = tool:WaitForChild("ShootEvent")
local reloadremote = tool:WaitForChild("ReloadEvent")
local Players = game:GetService("Players")
local client = Players.LocalPlayer
local char = client.Character
local head = char:WaitForChild("Head")
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local cursor = client:GetMouse()
local firerate = tool:GetAttribute("FireRate")
local maxammo = tool:GetAttribute("MaxAmmo")
local ammo = tool:FindFirstChild("Ammo")
local noAmmo = tool.HoldPart:WaitForChild("NoAmmo")
local reloadTime = tool:GetAttribute("ReloadTime")
local shootp = tool:WaitForChild("ShootPart")
local Anims = tool:WaitForChild("Anims")
local Hold = Anims:WaitForChild("Hold")
local Equip = Anims:WaitForChild("Equip")
local Fire = Anims:WaitForChild("Fire")
local LoadedHold = hum:LoadAnimation(Hold)
local LoadedEquip = hum:LoadAnimation(Equip)
local LoadedFire = hum:LoadAnimation(Fire)
local canfire = true
local isIdle = true
local equiped = false
local function IdlePlay()
if isIdle == true then
LoadedHold:Play()
end
end
tool.Equipped:Connect(function()
LoadedEquip:Play()
canfire = true
isIdle = true
equiped = true
task.wait(0.3)
IdlePlay()
end)
tool.Activated:Connect(function()
if canfire == true then
if equiped == true then
canfire = false
isIdle = false
shootremote:FireServer(cursor.Hit.Position, head.CFrame.Position, head.CFrame.lookVector)
LoadedFire:Play()
task.wait(firerate)
canfire = true
else
noAmmo:Play()
end
end
LoadedFire.Stopped:Wait()
LoadedHold:Play()
end)
tool.Unequipped:Connect(function()
LoadedEquip:Stop()
LoadedHold:Stop()
LoadedFire:Stop()
isIdle = false
canfire = false
equiped = false
end)
Any help is appreciated!