Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why don't I receive my cloned item?

I basically made a tool and put it in game.Lighting and I made a script so that only the creator (me) gets it and I don't receive the tool in my backpack but no errors in output

local Players = game:GetService("Players")
     
    Players.PlayerAdded:Connect(function(player)
            if player.Name == "zle_n" then
			local dio = game.Lighting["Za Wardo"]:Clone()
			dio.Parent = game.Players.zle_n.Backpack
			local hi = game.Lighting.Selidus:Clone()
			hi.Parent = game.Players.zle_n.Backpack
                print("gave item to owner") -- this does print but no item in my backpack
            end
    end)

2 comments

0

set the parent to player:WaitForChild("Backpack") instead and see if it works

0

same problem :/

2 answers

✓ Accepted answer

this script should be in ServerScriptService

game.Players.PlayerAdded:Connect(function(player)
wait(3)
            if player.Name == "zle_n" then
            local dio = game.Lighting:WaitForChild("Za Wardo"):Clone()
            dio.Parent = game.Players.zle_n:FindFirstChild("Backpack")
            local hi = game.Lighting:WaitForChild("Selidus"):Clone()
            hi.Parent = game.Players.zle_n:FindFirstChild("Backpack")
                print("gave item to owner")
            end
    end)

The recommendation in the answer above is a bad one. Do not put anything else other than a script in ServerScriptService, if you have tools, put it in ServerStorage. You can put anything in Lighting, but exploiters can get it easily. And your script doesn't seem to have a problem, maybe just have to give it a little wait or use "WaitForChild". Hope this helps.

2 comments

0

Thank you very much, and yes I have put the items in ServerStorage

0

@ivorfy, didn't know where he had the script he posted, and my recommendation was mean't for parenting the tool, not the script. And even if it didn't work, it still would've provided more efficient code.

Everything takes its time to load, so consider using this.

game.Players["zle_n"]:WaitForChild("Backpack")

Also, lighting isn't where items should go, I recommend a folder in ServerScriptService

3 comments

0

ok did i ask?

0

It's recommended to put it somewhere like ReplicatedStorage or ServerStorage

0

And as ivorfy said, if you put it in lighting (or replicated storage) exploiters can clone the tool to his/her backpack. The client cannot ServerScriptService and ServerStorage so it would be safer

This discussion is preserved as it was. New answers, comments, and votes are closed.