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

How do I make this Game Pass disable and enable a script?!

I am bad at scripting and I found this script and edited it, but of course it was wrong. I want to make it where it enables or disables a script, FOR THE LOCAL PLAYER! I have the script below, please fix it!

Inside of {ServerScriptService} there are MainTokens and TokensDouble scripts. TokensDouble script is disabled and MainTokens is enabled!

I know it is game.Players.LocalPlayer.Something, but I don't know what. PLEASE HELP ME!

local passId = 910298336 -- change this to your game pass ID.
 
function isAuthenticated(player) -- checks to see if the player owns your pass
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId)
end
 
game.Players.PlayerAdded:connect(function(plr)
    if isAuthenticated(plr) then
	game.Players.LocalPlayer.PlayerScripts.MainTokens.Disabled = true
	game.Players.LocalPlayer.PlayerScripts.TokensDouble.Disabled = false
else
	game.Players.LocalPlayer.PlayerScripts.MainTokens.Disabled = false
	game.Players.LocalPlayer.PlayerScripts.TokensDouble.Disabled = true
    end
end)

1 answer

✓ Accepted answer

I didn't fully understand what you're intended to do, but hopefully this one will work, I am a noob myself.

local id = 910298336
local player = game.Player.LocalPlayer

if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, id) then 
    game.Players.LocalPlayer.PlayerScripts.MainTokens.Disabled = false -- if player have the Pass, the script is enabled.
else
   game.Players.LocalPlayer.PlayerScripts.MainTokens.Disabled = true -- if player don't have the Pass, the script is disabled.
end

2 comments

0

that didn't work

0

what do you mean by: "game.player.localplayer.playerscripts.maintokens"? where is that?

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