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

Why wont this onEntered work?[UNSOLVED]

Asked by 9 years ago

What this is supposed to do is when you join, it gives you a random element, makes a message saying your element and then clone the element tool from Lighting into the players backpack. There are no errors in the script but it wont work.

function onPlayerAdded(Player)
    Player:WaitForDataReady()
    Chakra = Instance.new("StringValue", Player)
    Chakra.Name = "Chakra"
    if Player:LoadString("Chakra") ~= "" then
        Chakra.Value = Player:LoadString("Chakra")
    else
        Elements = {"Water","Lighting","Fire","Wind","Earth"}
        i = math.random(1,#Elements)
        Players.Chakra.Value = Elements[i]
        Player:SaveString("Chakra", Player.Chakra.Value)
        Message = Instance.new("Message", Workspace)
        Message.Text = Chakra.Value
        game.Debris:AddItem(Message,10)
    end
    if Player.Chakra.Value == "Fire" then
        x = game.Lighting.Fireball:clone()
    elseif Player.Chakra.Value == "Water" then
        x = game.Lighting.Water:clone()
    elseif Player.Chakra.Value == "Lighting" then
        x = game.Lighting.Lighting:clone()
    elseif Player.Chakra.Value == "Wind" then
        x=game.Lighting.Wind:clone()
    elseif Player.Chakra.Value == "Earth" then
        x=game.Lighting.Earth:clone()
    end
    x.Parent = Player.Backpack
end

game.Players.PlayerAdded:connect(onPlayerAdded)
0
Random downvoters... ggggyourface23 63 — 9y

1 answer

Log in to vote
2
Answered by
bbissell 346 Moderation Voter
9 years ago

You have a typo on Line 10.

Players.Chakra.Value = Elements[i]

"Players" is not defined. However, "Player" is defined.

0
Thanks so much :) ggggyourface23 63 — 9y
0
No problem. Please don't forget to Up Vote as well! bbissell 346 — 9y
Ad

Answer this question