Problem with the tool after being duplicated in player's backpack

Hello, I meet here a big trouble ;

Now, I have a tool in starterpack that works. However, I don’t want the tool to be in the starter pack. I want a giver with it and I decided to put the thing into serverStorage, as I tried with Lighting. The tool is in, the giver works.

But the tool doesn’t, after the giver copies the tool in the inventory ; I mean by that, that you can equip the tool, but the script inside doesn’t seem to trigger. I have no idea of what is the problem with that. Here is the script of the tool, a local script ;

Here is the code,

local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local h = char:WaitForChild("Humanoid")
local binocular = script.Parent.Zeiss
local Camera = workspace.Camera

Binocular = script.Parent:WaitForChild("BinocularGUis")

local DefaultFov = workspace.Camera.FieldOfView

local tempdis = game.Players.LocalPlayer.CameraMaxZoomDistance
-- Animations ; --------------------------------------

local anim1 = h:LoadAnimation(script.Parent:WaitForChild("A1"))
local anim2 = h:LoadAnimation(script.Parent:WaitForChild("A2"))
local anim3 = h:LoadAnimation(script.Parent:WaitForChild("A3"))
local anim4 = h:LoadAnimation(script.Parent:WaitForChild("A4"))
local anim6 = h:LoadAnimation(script.Parent:WaitForChild("A6"))

------------------------------------------------------
local state = true
local tool = script.Parent

tool.Equipped:Connect(function()
	binocular.Transparency = 1
	anim6:Play()
	wait(1.24)
	anim6:Stop()
	binocular.Transparency = 0
	anim1:Play()
	
	if Binocular.Parent == player.PlayerGui then
		print("Hey!")
	else
		Binocular.Parent = player.PlayerGui
	end
end)

tool.Activated:Connect(function()
	
	
	
	if state == true then
		
		anim1:Stop()
		anim2:Play()
		wait(0.18)
		anim2:Stop()
		anim3:Play()
		
		player.Character.Humanoid.CameraOffset = Vector3.new(0,0,-3)	
		
		game.Players.LocalPlayer.CameraMaxZoomDistance = 0
		
		local Gui = script.Parent.binreticle:Clone()
		Gui.Parent = player.PlayerGui.BinocularGUis
		
		Camera.FieldOfView = 10
		
		state = false		
		
	else
		
		anim3:Stop()
		anim4:Play()
		wait(0.18)
		anim4:Stop()
		anim1:Play()
		
		player.Character.Humanoid.CameraOffset = Vector3.new(0,0,0)
		
		game.Players.LocalPlayer.CameraMaxZoomDistance = tempdis
		
		Camera.FieldOfView = DefaultFov
		
		if player.PlayerGui.BinocularGUis:FindFirstChild("binreticle") then
			for i,v in pairs(player.PlayerGui.BinocularGUis:GetChildren()) do
				v:Destroy()
			end
		end

		state = true
		
	end
	
	
	
end)

tool.Unequipped:Connect(function()
	anim1:Stop()
	anim2:Stop()
	anim3:Stop()
	anim4:Stop()
	anim6:Stop()
	
	player.Character.Humanoid.CameraOffset = Vector3.new(0,0,0)

	game.Players.LocalPlayer.CameraMaxZoomDistance = tempdis
	
	Camera.FieldOfView = DefaultFov
	
	if player.PlayerGui.BinocularGUis:FindFirstChild("binreticle") then
		for i,v in pairs(player.PlayerGui.BinocularGUis:GetChildren()) do
			v:Destroy()
		end
	end
	
	state = true
	
end)

I maybe need to give you that thing as well, that is my folder configuration into the tool. It may change if the trouble comes from there.

image

And the giver. The giver actually works. The problem is with the tool itself.

local tool = game.ServerStorage:WaitForChild("Zeiss binoculars")

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    if player then
        local give = tool:Clone()
        give.Parent = player.Backpack
    end
end)

Thanks for helping.

I finally found where the problem was. I was trying to change part transparency in the localscript, instead of doing that in a different serverscript.

hey so apparently this bug has happened to a couple of users who try to clone objects and the object scripts just stop working for no reason, but it has something to do with CollectionService which you can read here.
(ah nvm if its already fixed ill leave this here if you wanna read it.)

1 Like

Anyway, you took the time to reply, thank you mate !

1 Like