My gun doesn't work when cloned from ServerStorage

  1. What do you want to achieve? Keep it simple and clear!
    I want to fix the problem with my gun’s cloning system
  2. What is the issue? Include screenshots / videos if possible!
    The gun only works when it is put in StarterPack and given to the player, but when it is duplicated, it glitches for some reason, and my sights don’t work on the gun.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have already tried changing the cloning system in the serverscript

Clone script:

local FirstPlayerIn = game.ReplicatedStorage:WaitForChild("FirstPlayerIn")
FirstPlayerIn.OnServerEvent:Connect(function()
	wait(1)
	FirstPlayerIn:Destroy()
end)
local FIRE = game.ReplicatedStorage:WaitForChild("SpawnInMap")
local FIRES = game.ReplicatedStorage:WaitForChild("SpawnInMapServer")
local timer = game.ReplicatedStorage:WaitForChild("Timer")
for i = 1,30 do
    timer.Value -= 1
	wait(1)
	end  
game.ReplicatedStorage["Sky (NOT MINE 2)"].Parent = game.Lighting
FIRE:FireAllClients()
game.Workspace.SpawnLocation.Position = Vector3.new("392.95, 4.964, 492.235")
wait(0.1)
	FIRES:Fire()
	script.Parent.Meteors.Enabled = true
	script.Parent.Meteors2.Enabled = true
	script.Parent.Meteors4.Enabled = true
	script.Parent.Meteors3.Enabled = true
	local StarterPack = game.ServerStorage.M1911:Clone()
StarterPack.Parent = game.StarterPack
for _,player in ipairs(game.Players:GetPlayers()) do
	local character = player.Character or player.CharacterAdded:Wait()
	if player then
		local startingweapon = game.ServerStorage.M1911:Clone()
		startingweapon.Parent = player.Backpack
	end
	character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.SpawnMap1.Position + Vector3.new(0,3,0))
end
wait(1)
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.SpawnMap1.Position + Vector3.new(0,3,0))
	end)
end)
1 Like

This needs to be written as

game.Workspace.SpawnLocation.Position = Vector3.new(392.95, 4.964, 492.235)

Lol that fixes another silly error I made, but the gun is still glitching for some reason

Do you have any errors in your output?

1 Like

No I don’t… I don’t have one when I put it in the StarterPack either (btw it only works when I put it in starterPack for some reason)

Here’s the ADS code though:

game:GetService("RunService").RenderStepped:Connect(function(dt)
	local ts = game:GetService("TweenService")
	local cam = workspace.CurrentCamera
	local aimPart = script.Parent.Parent:WaitForChild("AimPart")
	local Time = 0.15 
	local function calculateSine(speed)
		sinValue += speed * 0.6
		if sinValue > (math.pi * 2) then sinValue = 0 end
		local sineY = 0.01 * math.sin(2 * sinValue)
		local sineZ = 0.01 * math.sin(sinValue)
		local sineCFrame = CFrame.new(sineZ, sineY, 0)
		return sineCFrame
	end
	if not zooming and player.PlayerScripts.Sprint.Value == false then
		local sineCFrame = calculateSine(0.04)
		if resetArm == false then
		resetArm = true
		aimPart.CFrame = (cam.CFrame * restPosition * sineCFrame):lerp(cam.CFrame * aimPosition, lerpd)
		ts:Create(cam, TweenInfo.new(0.2), {FieldOfView = 80}):Play()
		player.PlayerScripts.Zoom.Value = false
		end
	elseif zooming and player.PlayerScripts.Sprint.Value == false and player.PlayerScripts.Crouching.Value == false then
		player.PlayerScripts.Zoom.Value = true
		ts:Create(cam, TweenInfo.new(Time), {FieldOfView = 30}):Play()
		resetArm = false
		local sineCFrame = calculateSine(0.02)
		aimPart.CFrame = (cam.CFrame * restPosition):lerp(cam.CFrame * aimPosition * sineCFrame, lerpd)
	end
end)