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

How can I make this script work? [closed]

Asked by 10 years ago

This is suppose to give plays on spawn random weapon can you please tell me whats wrong with it?

player = part.Parent:findFirstChild("Humanoid")


function onPlayerEntered(player)

local Item = game.Lighting:FindFirstChild(math.random)

Item:clone().Parent = player.Backpack
    wait(2)

print 'Working'

end




game.Players.PlayerAdded:connect(onPlayerEntered)
onPlayerEntered(game.Players:WaitForChild("Player1"))

Locked by fireboltofdeath and Articulating

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
1
Answered by 10 years ago

Judging by your attempt, the items are in game.Lighting. So if its not please PUT EM THERE. Use this. It will put it in their backpack NOT their startergear so if they die they dont obtain it again but if you want them to just keep spawning random items when they spawn reply with a yes and ill come up with a quick script :D

function GiveWeap(des)
    local items = game.Lighting:GetChildren()
    items[math.random(1,#items)]:Clone().Parent = des.Backpack
end

game.Players.PlayerAdded:connect(function(plr)
    plr:WaitForChild("Backpack")
    GiveWeap(plr)
end)
0
So i guess yes id like them to receive the same item even though they died Revenant101 25 — 10y
Ad
Log in to vote
1
Answered by 10 years ago

At the top 'findFirstChild' is supposed to be FindFirstChild. You also have two player variables. You may need to change one of the variables to something else. 'Item:clone()' should be Item:Clone(). Other than that I don't know, sorry.

0
Thank you but there is still something that make it wrong or something needed to make it work Revenant101 25 — 10y
0
Actually. FindFirstChild and findFirstChild are correct. fireboltofdeath 635 — 10y