Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Changing an IntValue on click and repeatedly checking to see if player has gamePass- Help?

I am making a script where when the player clicks the textbutton the intValue's value goes up by the upgrade (another intValue with the second script in it). The click script is here, and the output is: attempt to index global 'script' (a nil value)

upgrade = script.Parent.Parent.TextLabel.Upgrade -- this is a local script
number = script.Parent.Parent.TextLabel.Number

script.Parent.MouseButton1Click:connect(function()
	number.Value = ""..number.Value + upgrade.Value
end)

This script is in an IntValue(not the textButton like above) and the IntValue is a child to a textlabel. The ouput is: attempt to index local 'player' (a nil value)

local pass = 182358984 -- this is not a local script
local player = game.Players.LocalPlayer

function Auth(player)
	return game:GetService('GamePassService'):PlayerHasPass(player.UserId, pass)
end

while true do
	if Auth() then
		script.Parent.Value = 3
	else
		script.Parent.Value = 1
	end
end

if you could answer one that would be good too.

1 comment

0

Is the second script a localscript?

1 answer

"game.Players.LocalPlayer", You can only do that in a LocalScript.

This discussion is preserved as it was. New answers, comments, and votes are closed.