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

Why does this click script not work? [BlueTaslem please answer]

Asked by 9 years ago

The error for the script is: local player = game.Players.LocalPla:3: attempt to index global 'script' (a nil value) If you're wondering, number is a stringValue and upgrade is an IntValue.

local pass = 182358984
local player = game.Players.LocalPlayer
upgrade = script.Parent.Parent.TextLabel.Upgrade
number = script.Parent.Parent.TextLabel.Number

function Auth(player)
    return game:GetService("GamePassService"):PlayerHasPass(player, pass)
end

script.Parent.MouseButton1Click:connect(function()
    if Auth() then
        upgrade.Value = 3
    else
        upgrade.Value = 1
    end
    number.Value = number.Value + upgrade.Value
end)

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

I don't see why you're getting that error specifically, but there is a bug in this code, specifically the Auth function.

You define Auth with a player parameter, overriding your player local variable for the scope of the function. Then, when you call Auth, you don't pass in any argument.

To fix that, just remove player from the parameter list for Auth.

0
I swear nothing works for this script. Can BlueTaslem answer this script please? raystriker6707 30 — 9y
Ad

Answer this question