Tool not working after cloning and moving it with the server

I’m trying to clone a “Tool” from the ReplicatedStorage to a player’s “Backpack” with the server, but the tool scripts just won’t activate, but the scripts do work when I get the tool from “StarterPack” when the game starts

I tried enabling and disabling the scripts with the server while the game is running and same with the tool object itself but still didn’t worked, functions like :activated, :equipped etc does not work

1 Like

You need to use RemoteEvents to make the tool work ReplicatedStorage breaks all your scripts no matter what lol

RemoteEvents fix this error it is built in the game
ReplicatedStorage just built different :cold_face:

but the tool works with remote events though, or do you want me to clone it with a remote event?

Make the scripts in the tool work with remote events using a localscript to fire it then the server to do stuff

but that’s how it already works

Are you cloning it on the client?

I’m cloning it with a script, not a local script (the script is in workspace)

Show me your code for your tool and script

we need to see the script to help you

That’s where the tool is located and the code is in a local script

Screenshot_2

local function onActivate()
    script.Parent.FireEvent:FireServer(playerMouse.Hit.Position)
end

local function onEquip()
    equipped = true
end

local function onUnequip()
    equipped = false
end

script.Parent.Equipped:Connect(onEquip)
script.Parent.Unequipped:Connect(onUnequip)
script.Parent.Activated:Connect(onActivate)

what exactly do you want to do? you said you had trouble cloning the tool which doesnt make sense considering that you’re firing the position

I’m trying to make like a weapon giver, when you touch the weapon giver it will clone the tool and put it into the player’s backpack

can you show the code that clones the tool?

but when the tool gets cloned, the scripts just won’t work, no errors not anything

1 Like
local marketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")

local gamepassId = script.Parent:GetAttribute("GamepassId")
local weaponName = script.Parent:GetAttribute("WeaponName")

local debounce = false
local cooldown = 5

local function onTouch(hit)
	if not debounce then
		if hit.Parent:FindFirstChild("Humanoid") then
			local selectedPlayer = players:GetPlayerFromCharacter(hit.Parent)
			
			if gamepassId ~= 0 then
				local gamepassCheck = marketplaceService:UserOwnsGamePassAsync(selectedPlayer.UserId, gamepassId)

				if gamepassCheck then
					if not selectedPlayer.Backpack:FindFirstChild(weaponName) and not hit.Parent:FindFirstChild(weaponName) then
						for i, v in pairs(game.ReplicatedStorage.SystemSaves.Weapons:GetChildren()) do
							if v.Name == weaponName then
								debounce = true
								
								local newWeapon = v:Clone()
								newWeapon.Parent = selectedPlayer.Backpack
								
								wait(cooldown)
								debounce = false
							else
								print("Weapon not found!")
							end
						end
					end
				else
					selectedPlayer:Kick("Banned for Cheating")
				end
			else
				if not selectedPlayer.Backpack:FindFirstChild(weaponName) and not hit.Parent:FindFirstChild(weaponName) then
					for i, v in pairs(game.ReplicatedStorage.SystemSaves.Weapons:GetChildren()) do
						if v.Name == weaponName then
							debounce = true

							local newWeapon = v:Clone()
							newWeapon.Parent = selectedPlayer.Backpack

							wait(cooldown)
							debounce = false
						else
							print("Weapon not found!")
						end
					end
				end
			end
		end
	end
end

script.Parent.Touched:Connect(onTouch)
1 Like

could you show the code that actually clones the given weapon?

1 Like

It checks if you have a specific gamepass, then it clones the tool and put’s it into the inventory if you don’t have the tool already and all of it works perfectly but once the tool is cloned and moved into the player’s backpack, the scrips are just not working

1 Like

so theres more tools in your weapons folder as well?

yes, but all of them have the same concept and all of them don’t work when cloned and moved, but all of them do work when I get them from the StarterPack at start