Leone984
(Leone)
October 30, 2022, 5:57pm
1
local plr = game.Players.LocalPlayer
local mps = game:GetService("MarketplaceService")
local id = 99789714
if mps:UserOwnsGamePassAsync(plr.UserId, id) then
game.Lighting.color.Parent = game.Workspace
end
This game pass only works on Roblox Studio and not in the game. I appreciate any help.
GuySalami
(GuySalami)
October 30, 2022, 6:00pm
2
Are there any errors in the game, like in the console? Also maybe try adding a wait(1) before the if statement.
bujirokun
(KnownAsTelly)
October 30, 2022, 6:00pm
3
Try converting this into a server script, then only run the script when the player has fully loaded.
Leone984
(Leone)
October 30, 2022, 6:02pm
4
Workspace.script:5: attempt to index nil with 'UserId'
1 Like
bujirokun
(KnownAsTelly)
October 30, 2022, 6:03pm
5
That is probably because it’s in a localscript.
1 Like
GuySalami
(GuySalami)
October 30, 2022, 6:03pm
6
LocalPlayer needs to be in a localScript.
1 Like
Have you enabled access to api services?
1 Like
Leone984
(Leone)
October 30, 2022, 6:03pm
8
it’s already a localscript. I just changed the name to Script
1 Like
GuySalami
(GuySalami)
October 30, 2022, 6:04pm
9
How is it running in the workspace then?
Leone984
(Leone)
October 30, 2022, 6:06pm
10
I just put it in workspace
(limitt)
bujirokun
(KnownAsTelly)
October 30, 2022, 6:06pm
11
local MPS = game:GetService("MarketPlaceService")
local ID = 99789714
game.Players.PlayerAdded:Connect(function(plr)
if MPS:UserOwnsGamePassAsync(plr.UserId, ID) then
game.Lighting.Color.Parent = game.Workspace
end
end)
Try this, put it as a serverscript in serverscriptservice
Leone984
(Leone)
October 30, 2022, 6:10pm
12
Unfortunately it doesn’t work, thanks anyway.
bujirokun
(KnownAsTelly)
October 30, 2022, 6:10pm
13
Where is your script located by the way?
Leone984
(Leone)
October 30, 2022, 6:12pm
14
I deleted the old localscript in workspace and made a new one in serverscriptservice, this time server script.
bujirokun
(KnownAsTelly)
October 30, 2022, 6:13pm
15
You have both a receipt script and the gamepass script right?
Also, localscripts can’t run anywhere like serverscripts
Leone984
(Leone)
October 30, 2022, 6:14pm
16
I don’t have a receipt script.
GuySalami
(GuySalami)
October 30, 2022, 6:15pm
17
You can’t use LocalPlayer in a server script, so are you using the PlayerAdded function?
bujirokun
(KnownAsTelly)
October 30, 2022, 6:15pm
18
Okay, keep your original localscript for now.
1 Like
GuySalami
(GuySalami)
October 30, 2022, 6:17pm
20
Ah, my bad, are there currently any errors in the console now, and maybe try print statements or breakpoints.