So basically the title says it all i dont know what more to say sorry. well i have a piece of code but it isnt working so im asking for advice on why its not working here
I have a part with a clickdetector and a script with following content:
clickdetector.MouseClick:Connect(function() ChemicalXR = Instance.new ("Tool") ChemicalXR.Parent = game.StarterPack ChemicalXR.Name = ("ChemicalXR") Handle = Instance.new ("Part") Handle.Parent = game.StarterPack.ChemicalXR Handle.Name = ("Handle")
so it does create the tool and the handle in the starterpack but not ingame so you cant equip them.
What you need to do is to get a tool like what noobest_khun said and put it somewhere not "physical", such as lighting or replicated storage. Afterwards, you would make a clone in your script and set the clones parent to the players backpack because making one from a script like that would be a LOT of work.
local clickdetector = script.Parent.ClickDetector --(Wherever your clickdetector is) local Tool = game.Lighting.Tool --Set tool to the name of the tool you made in lighting function onClick(Clicker) local c = game.Lighting.Tool:Clone() c.Parent = Clicker.Backpack end clickdetector.MouseClick:Connect(onClick)
Dont use StarterPack. Use Backpack from the local player. Heres the fixed version(not tested)
clickdetector.MouseClick:Connect(function() for i,v in pairs(game.Players:GetPlayers()) do ChemicalXR = Instance.new ("Tool") ChemicalXR.Parent = v.Backpack ChemicalXR.Name = ("ChemicalXR") Handle = Instance.new ("Part") Handle.Parent = ChemicalXR Handle.Name = ("Handle") end
I hope this worked and helped!