G’day all,
I’ve been struggling for a few days with a really really strange bug. I’ll try and outline it as best as I can.
Basically, I’m trying to clone a tool from ServerStorage or ReplicatedStorage, or even Workspace (I’ve tried all).
It works fine in studio:
(Above) playing the game in studio environment. (below) Studio output
![](http://devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/4X/f/c/6/fc602143029d5394592c653cf5406229b435a7a8.png)
But not on the Roblox client:
Even though the server reports that it exists:
The only thing I haven’t tried is moving the block of code doing the cloning into a separate module.
-- this is the script that manages equip
function EquipSword(player, sword, setupFinished)
-- Current equipped Sword, defaults to Default Sword
local EquippedSword = Datastore2("OwnedSwords", player)
local v16 = EquippedSword:GetTable({"Default Sword"})
local Equipped = Datastore2("EquippedSword", player)
local v18 = Equipped:Get("Default Sword")
if table.find(v16, sword) then
if WeaponStore[sword] then -- Check that the sword is a thing
-- Cloning the sword to the player backpack
local Temp = WeaponFolder:FindFirstChild(sword):Clone()
Temp.Parent = player.Backpack
CollectionService:AddTag(Temp, "Weapon")
print("gave player weapon", Temp:GetFullName())
else
warn("Invalid sword!")
end
else
warn("Player does not own sword!\n" .. sword)
end
end
As you can see by the printouts, it works fine.
-- this is the script that manages weapon functions
function SwordClass.new(sword, player)
local self = {}
setmetatable(self, SwordClass)
self.Owner = player
self.Weapon = sword
self.Data = nil
self.Cooldown = 0.5
self.TimeSinceLastAttack = tick()
self.Activated = sword.Activated:Connect(function()
self:Activate()
end)
self:Init()
end
function SwordClass:Init()
print("Initialised sword", self.Weapon:GetFullName())
end
I even tried something as simple as:
game.Players.PlayerAdded:Connect(function(player)
local new = script.Tool:Clone()
new.Parent = player.Backpack
end)
All to no avail. It’s leading me to think that this may be a replication issue, as it works just fine in the Studio environment.
Devforum is my last resort as the game is due to release soon and I have no idea what the issue could be. I haven’t tried it out on a fresh game yet, but I’m led to believe that won’t fix it.
Let me know if you need more info.
Thanks!