WIP Gun system view models causing player to fling across the map

  1. What do you want to achieve?

I wanna make it so the gun and arms are view models in my gun system.

  1. What is the issue?

Upon equipping the gun the character starts flinging across the map.

  1. What solutions have I tried so far?

Deleting certain objects like welds or the humanoid in the arm view model. Some of them would actually fix the issue but on the other hand they would cause stuff to fall in the void or just stop working.

I have looked at other posts before posting as well as trying different tutorials for view models, different arm models, etc.

Any help is appreciated, thank you.

Video of the problem: (For some reason uploading it normally doesn’t work)

External Media

Module Script in Replicated Storage, called by the client.

local UDS_GSys = {}

local physicsService = game:GetService("PhysicsService")
local player = game:GetService("Players").LocalPlayer
local camera = game.Workspace:WaitForChild("Camera")

local defaultMaxZoom = nil
local defaultCameraType = nil
local defaultMinZoom = nil
local defaultIcon = nil

function UDS_GSys.intialize(tool, offset)
	viewModel = game.ReplicatedStorage:WaitForChild("GunSystem"):WaitForChild("Viewmodel"):Clone()
	viewModel.Parent = camera
	if offset == nil then
		warn("Missing weapon offset, autosetting in order to prevent an error.")
		offset = CFrame.new(1, -1.5, -2)
	viewModel.LeftArm.Color = player.Character:FindFirstChild("Left Arm").Color
	viewModel.RightArm.Color = player.Character:FindFirstChild("Right Arm").Color
    viewTool = tool:Clone()
	viewTool.Parent = camera
	viewTool.PrimaryPart.CFrame = viewModel.RightArm.CFrame
	for i, v in pairs(viewTool:GetDescendants()) do
		if v:IsA("Part") or v:IsA("MeshPart") then
			v.CollisionGroup = "Viewmodel"
	for i, v in pairs(viewModel:GetDescendants()) do
		if v:IsA("Part") or v:IsA("MeshPart") then
			v.CollisionGroup = "Viewmodel"

	local joint = Instance.new("Motor6D");
	joint.C0 = offset;
	joint.Part0 = viewModel.RightArm;
	joint.Part1 = tool.Handle;
	joint.Parent = viewModel.RightArm;
	defaultMaxZoom = player.CameraMaxZoomDistance
	defaultCameraType = player.DevEnableMouseLock
	defaultCameraType = camera.CameraType
	defaultMinZoom = player.CameraMinZoomDistance
	defaultIcon = player:GetMouse().Icon
	player.CameraMaxZoomDistance = 0.5
	camera.CameraType = Enum.CameraType.Custom
	player.CameraMinZoomDistance = 0.5
	player:GetMouse().Icon = "rbxassetid://0"
	player:WaitForChild("PlayerGui"):WaitForChild("UDS_GSys").Enabled = true

function UDS_GSys.disconnect()
	player.CameraMaxZoomDistance = defaultMaxZoom
	defaultCameraType = defaultCameraType
	player.CameraMinZoomDistance = defaultMinZoom
	player:WaitForChild("PlayerGui"):WaitForChild("UDS_GSys").Enabled = false

game["Run Service"].RenderStepped:Connect(function()
	if viewModel and camera:FindFirstChild("Viewmodel") and player.Character:FindFirstChild("Humanoid").Health ~= 0 then
		viewModel.HumanoidRootPart.CFrame = camera.CFrame * CFrame.new(0,0,0)

return UDS_GSys

Edits: Trying to fix the video as for some reason it wasn’t working with streamable.

1 Like

Fixed the issue myself, it had to do with the weld fighting against each other.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.