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

What is happening with my simple "Give a certain player a tool" script? [Solved]

Asked by 9 years ago

This is just a script inside of workspace. It's working weirdly and I don't know if I did something and I don't notice a simple error or what, but my script is suppose to give a certain player a tool when they enter and if they were to die, they'd get said tool again.

Here's the script:

A = "alphawolvess"
L = "ThisPersonIsASecretSooooyea" -- Not what's actually there, but I wont give out his name in case he prefers not to have it out.
Test = "Player"

game.Players.PlayerAdded:connect(function(Plr)
    Plr.CharacterAdded:connect(function(Char)
        if Char.Name == L or Char.Name == A or Char.Name == Test then
            print("Giving")
            local Copy = game.ServerStorage:FindFirstChild("RedKatana")
            Copy.Parent = Plr.Backpack
        else
            print("Not Giving")
        end
    end)
end)

Yes, I know I can use a generic loop and store the names in a Table. I also know I can use string.lower but the spelling for players is correct. Also, I do know that Player changes from Player1 to Player for some reason, currently (for me) it's Player and I change that if needed. I do get an error about Local Copy being nil

0
That means that 'RedKatana' doesn't exist. DigitalVeer 1473 — 9y
0
Minor note: If you're going to assume that Copy is non-nil (line 9), there's no need to use FindFirstChild at all - just do local Copy = game.ServerStorage.RedKatana (and as said below, add a :Copy() somewhere in this area) chess123mate 5873 — 9y
0
I know what happened, I didn't clone it so I moved the existing Katana into the first joined allowed player and it was no longer there to use. alphawolvess 1784 — 9y

2 answers

Log in to vote
2
Answered by 9 years ago

I don't know if it's the error or not, but it seems you never actually clone the sword. You index it and attempt to move it, but never physically clone it.

0
Oh yea I did it then accidentally removed it and completely forgot about Clone() alphawolvess 1784 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

You need to actually clone the katana on line 10.

Copy:Clone().Parent = Plr.Backpack

Also you can just use Plr.Name

Answer this question