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

Gamepass Works while testing but not in game?

Asked by
DBoi941 57
6 years ago

I think its because of "LocalPlayer" but I am not sure. I am trying to move the TarantulaPet to the players character folder.

01local gamePassID = 0000000
02local function onPlayerAdded(player)
03 
04    local hasPass = false
05 
06    local success, message = pcall(function()
07        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
08    end)
09 
10    if not success then
11        warn("Error while checking if player has pass: " .. tostring(message))
12        return
13    end
14 
15    if hasPass == true then
View all 22 lines...
0
Is this in a local script? chomboghai 2044 — 6y

1 answer

Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
6 years ago

You don't need to use game.Players.LocalPlayer.Character, because the CharacterAdded event has the character argument passed in already. Even then, this should be a server script, so you can't use LocalPlayer in a server script.

1if hasPass then -- you don't need == true
2    player.CharacterAdded:Connect(function(character) -- change connect to Connect
3        game.ServerStorage:FindFirstChild("TarantulaPet"):Clone().Parent = character
4    end)
5end

Hope this helps! :)

0
Ok i see what you mean. Thank you very much. DBoi941 57 — 6y
Ad

Answer this question