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

Script not giving player the gear, no error? Please help

Asked by 4 years ago
Edited 4 years ago

Im fairly new to scripting; messy code that i came up in my head because im too small brain to think of a simpler way

game:GetService('Players').PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character:WaitForChild("Humanoid").Died:Connect(function()
            local Player = game.Players.LocalPlayer
            local number = math.random(1,4)
            if number == 1 then
                wait(6)
                print(1)
                local gear = workspace.Folder.ClassicSword:Clone()
                gear.Parent = Player
            elseif number == 2 then
                wait(6)
                print(2)
                local gear = workspace.Folder.RedHyperLaser:Clone()
                gear.Parent = Player
            elseif number == 3 then
                wait(6)
                print(3)
                local gear = workspace.Folder.HyperlaserGun:Clone()
                gear.Parent = Player
            elseif number == 4 then
                wait(6)
                print(4)
                local gear = workspace.Folder.Epicsword:Clone()
                gear.Parent = Player
            end
        end)
    end)
end)



1 answer

Log in to vote
1
Answered by 4 years ago

You don't put a tool in the actual Player, theres a Backpack child for all of the players, or you can parent it to the character, which will automatically equip it.

gear.Parent = Player.Backpack
0
thanks Radiant_Sparkles 69 — 4y
0
thanks Radiant_Sparkles 69 — 4y
0
wait it says attempt to index nil with backpack (i moved folder to serverstorage and changed code so its in server storage and its a script) Radiant_Sparkles 69 — 4y
1
local player does not exist on server, you already have variable for player on line 1, just remove line 5 and change all references of Player to player imKirda 4491 — 4y
View all comments (3 more)
0
ohhhh ok Radiant_Sparkles 69 — 4y
0
ohhhh ok Radiant_Sparkles 69 — 4y
0
thanks to both of you Radiant_Sparkles 69 — 4y
Ad

Answer this question