Script not working

How would i fix this script? Theres a bunch of red lines and its not working.

script.Parent.Parent = script.Parent.Parent.Head

local Player = game.Players:FindFirstChild(script.Parent.Parent.Parent.Name)

game.Players.PlayerAdded:Connect(function()

if Player:WaitForChild("leaderstats").Title.Value ~= "" and Player:WaitForChild("leaderstats").Title.Value ~= " " then

script.Parent.Holder.Tag.Visible = true

script.Parent.Holder.Tag.Text = Player:WaitForChild("leaderstats").Title.Value

end

end

Player:WaitForChild("leaderstats").Title.Value.Changed:Connect(function()

if Player:WaitForChild("leaderstats").Title.Value ~= "" and Player:WaitForChild("leaderstats").Title.Value ~= " " then

script.Parent.Holder.Tag.Visible = true

script.Parent.Holder.Tag.Text = Player:WaitForChild("leaderstats").Title.Value

end

end

Since you’re wrapping functions inside event listeners you need to include the closing parentheses.

1 Like

Oh okay. Thanks for the help. :slightly_smiling_face:

This isnt a very good script and has many inconsistent at many parts, you should probably add the Changed even inside the PlayerAdded event, also, you can have an argument within the Connect as the Player for PlayerAdded

game.Players.PlayerAdded:Connect(function(player) -- Argument within the Function
    print(player) -- prints the name of the Player that joined
end)

So with this, we now have the Player, then we can get or create the leaderstats value inside the Event, but in your case, we would check the Player for the Instance your Looking fir and do this:

-- Within the PlayerAdded Event I showed

    local Item = player:WaitForChild("leaderstats").Title -- Gtes the Instance HOlding the Value that is within the Plauer
    Holder.Tag.Text = Item.Value -- Applies the Value
    Item.Changed:connect(function(newValue) -- When a Property Changes
        Holder.Tag.Text = newValue -- Applies new Value
    end)

It would be much faster to do this.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.