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

I need help with using Player.Character in my shop script. Help?

Asked by 3 years ago

I want it to get the character from the player when the button is clicked, here's my script.

Button = script.Parent
Button.MouseButton1Up:Connect(function(Player)
    local char = Player.Character
    if char then
        if Player.leaderstats.Doges.Value >= 100 then
            Player.leaderstats.Doges.Value = Player.leaderstats.Doges.Value - 100
            char.Head.BillboardGui.TextLabel.BackgroundTransparency = 0
            char.Head.BillboardGui.TextLabel.TextTransparency = 0
            char.Head.BillboardGui.TextLabel.Text = "Noob"
        else
            Button.Sound.Playing = true
        end
    end
end)
0
What exactly is the problem? JustinWe12 723 — 3y
0
This is the error: Players.kennyb1023.PlayerGui.ScreenGui.Shop.ScrollingFrame.TextButton.Script:3: attempt to index number with 'Character' NeoDogez 18 — 3y
0
if the Button variable (script.Parent) is a GuiObject, then the event MouseButton1Up returns the X, Y positions of where MouseButton1 was let go. what you're actually doing is trying to do X.Character, but X is a number, not the player who clicked the button. Hence you get the error "index number with 'Character' guildedcow 30 — 3y
0
Thanks NeoDogez 18 — 3y

Answer this question