Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why don't I receive my cloned item?

Asked by
zle_n 9
5 years ago

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)
0
set the parent to player:WaitForChild("Backpack") instead and see if it works Hacreey 49 — 5y
0
same problem :/ zle_n 9 — 5y

2 answers

Log in to vote
0
Answered by
0msh 333 Moderation Voter
5 years ago

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.

0
Thank you very much, and yes I have put the items in ServerStorage zle_n 9 — 5y
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. Hacreey 49 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

0
ok did i ask? zle_n 9 — 5y
0
It's recommended to put it somewhere like ReplicatedStorage or ServerStorage mybituploads 304 — 5y
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 mybituploads 304 — 5y

Answer this question