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

My gamepass script wont work in an actual game but works in studio ?

I have this script to check if the player owns a gamepass and it works in studio but not in the actaul game, why ?

id = 1008824264
wait(10)
for i,v in pairs(game.Players:GetPlayers()) do
	if v then
		if game:GetService("GamePassService"):PlayerHasPass(v,id) then
			wait(1)
			game.Players.LocalPlayer.leaderstats.Points.Value = game.Players.LocalPlayer.leaderstats.Points.Value + 250
			game.Players.LocalPlayer.PlayerGui.MEGAVIPWALK.Enabled = true	
		end
	end
end

2 comments

0

Why do you need to do "if v then"?

2

you cant use localplayer in a serverscript...

1 answer

✓ Accepted answer
id = 1008824264
wait(10)
for i,v in pairs(game.Players:GetPlayers()) do
	if game:GetService("GamePassService"):PlayerHasPass(v,id) then
		wait(1)
		v.leaderstats.Points.Value=v.leaderstats.Points.Value + 250
		v.PlayerGui.MEGAVIPWALK.Enabled = true   
	end
end

Just change game.Players.LocalPlayer to v because game.Players.LocalPlayer doesn't work in server side scripts.

1 comment

0

Explain your answer in English. Don't just post code; this doesn't help the poster or the community understand why the code does what it does.

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