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

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

Asked by 6 years ago

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

Log in to vote
1
Answered by
0msh 333 Moderation Voter
6 years ago

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

0
that didn't work Goldenkings11 -11 — 6y
0
what do you mean by: "game.player.localplayer.playerscripts.maintokens"? where is that? 0msh 333 — 6y
Ad

Answer this question