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
That’s where the tool is located and the code is in a local script
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)
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)
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
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