THIS IS THE ERROR I GET
THIS IS THE SCRIPT IT SAYS IS WRONG
THIS IS HOW TO TOOL IS GETTING PLACED INTO THE PLAYERS BACKPACK FROM DATASTORE
THIS IS WHERE IT IS GETTING CLONED FROM SOME TIME I DONT GET A ERROR AND OTHER TIMES I DO
THIS IS THE ERROR I GET
does your tool still exist within your hand when you equip it? this seems like it may be an issue with the tool getting destroyed instead of a datastore problem. If the script is running it means that the datastore script successfully did its job and enabled the script.
edit: also I recommend adding more prints to narrow down the issue.
maybe try printing the contents of the datastore and seeing if they are correct and also try printing the tool multiple times and seeing at what point it becomes nil instead of a tool.
it gets copied the somehow gets removed but there is nothing causing it to be removed it is just randomly doing it and like i said sometime it works and other times it wont work
and it is not too close to the world void? is there any type of motor or joint in it? i have had problems before with those causing tools and objects to glitch out and destroy themselves by getting flung into the void randomly.
they are placed under ground maybe it is not moving them quick enough and they are getting flung away
It seems that it is a Roblox bug. I was attempting to recreate you scenario and it appears that any tool that you attempt to move from replicated storage or server storage into the player backpack destroys itself for some reason (although for me it is almost 100% destroy rate idk why). I manage to put together a temporary solution though.
-- Make the PrimaryPart of the Tool Anchored (or any part in the tool, just change ".PrimaryPart" to that part)
local New = game.ServerStorage:WaitForChild("Tool"):Clone() -- make new part
New.Parent = game.Workspace -- move to workspace (maybe keep the part at some place where it wont bother players during this time period)
wait(.55) -- this was the shortest wait I could get without any problems occoring occasionally.
New.Parent = Plr.Backpack -- move from workspace to backpack now
New.PrimaryPart.Anchored = false -- unanchor primary part
this is what I did but isn’t the best, just makeshift since it has problems such as the object being in the way while inside the workspace, having to anchor it to have it not fall then un-anchor it to make it as a normal tool again, and the slow spawn from the wait method.
oop forgot to hit submit yesterday woops.
Ok I made a new Solution better than my last I think but haven’t tested it enough to know if it has any flaws. So far it seems to work though.
local TargetToolName = "Tool" -- replace this with the target tool name (or replace the uses of it in the code with the target tool name)
game.Players.PlayerAdded:Connect(function(Plr)
if not game.ServerStorage:FindFirstChild(TargetToolName) then
repeat task.wait() until game.ServerStorage:FindFirstChild(TargetToolName) or task.wait(5) -- similar to WaitForChild() but wont break code :)
end
local TargetTool = game.ServerStorage:FindFirstChild(TargetToolName)
if TargetTool then
while wait() do -- loop new tool creation
local New = TargetTool:Clone() -- create the new tool
New.Parent = Plr.Backpack -- parent the new tool
wait() -- slight wait cause it didn't work without it.
-- it seems that the tool gets destroyed in the span of a wait.
-- if this stops working I recommend trying to extend this wait slightly
if New and New.Parent == Plr.Backpack then
break -- if the Tool cloning was a success, the loop will stop and only create one Tool
else
if New then
New:Destroy() -- Destroy the New Tool if it still exists but failed to parent for some reason.
end
warn("Failed To Clone Tool To Backpack") -- Otherwise, it will keep the loop going with a warning of the failure
end
end
else
warn("Failed to locate Target Clone Tool")
end
end)
-- edit: task.wait() didn't work for the loop so it is just normal wait() methods
this should be better because it works differently. instead of trying to work with 1 tool it will attempt to keep creating a new tool over and over until it successfully manages to clone the tool and parent it
edit 2 – here is a customized version of the script for you, hopefully I got it right idk cause I can’t test it due to not having the same setup in-game.
if data.Backpack then
for i,TargetToolName in ipairs(data.Backpack) do
if not game.ServerStorage:FindFirstChild(TargetToolName) then
repeat task.wait() until game.ServerStorage:FindFirstChild(TargetToolName) or task.wait(5) -- similar to WaitForChild() but wont break code :)
end
local TargetTool = game.ServerStorage:FindFirstChild(TargetToolName)
if TargetTool then
while wait() do -- loop new tool creation
local New = TargetTool:Clone() -- create the new tool
New.Parent = plr.Backpack -- parent the new tool
wait() -- slight wait cause it didn't work without it.
-- it seems that the tool gets destroyed in the span of a wait.
-- if this stops working I recommend trying to extend this wait slightly
if New and New.Parent == plr.Backpack then
warn("Success Cloning Tool To Backpack")
if not New:FindFirstChild("LocalController") then
repeat task.wait() until New:FindFirstChild("LocalController") or task.wait(5) -- similar to WaitForChild() but wont break code :)
end
local LocalController:LocalScript = New:FindFirstChild("LocalController")
if LocalController then
LocalController.Enabled = true
end
break -- if the Tool cloning was a success, the loop will stop and only create one Tool
else
if New then
New:Destroy() -- Destroy the New Tool if it still exists but failed to parent for some reason.
end
warn("Failed To Clone Tool To Backpack") -- Otherwise, it will keep the loop going with a warning of the failure
end
end
else
warn("Failed to locate Target Clone Tool")
end
end
end