I'm not sure what's going wrong
local PassId = 4835177 local ReplicatedStorage = game:GetService("ReplicatedStorage") local MarketplaceService = game:GetService("MarketplaceService") local player = game.Players.LocalPlayer local bloxy = workspace:WaitForChild("itemgiver1") local debounce = false script.Parent.Touched:connect(function(hit) local user = hit.Parent if MarketplaceService:UserOwnsGamePassAsync(user.UserId, PassId) then if hit.Parent:FindFirstChild('Humanoid') then hit.Parent.Torso.CFrame = CFrame.new(1999971.875, 53.506, -21.966) hit.Parent.UpperTorso.CFrame = CFrame.new(1999971.875, 53.506, -21.966) end else MarketplaceService:PromptGamePassPurchase(user, PassId) end end)
LocalPlayer
is nil on the server. It can only be used on the client. Get the player with GetPlayerFromCharacter
.local PassId = 4835177 local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local MarketplaceService = game:GetService("MarketplaceService") local bloxy = workspace:WaitForChild("itemgiver1") local debounce = false local pos = CFrame.new(1999971.875, 53.506, -21.966) local getPlayerFromCharacter local player getPlayerFromCharacter = function(model) local plr = Players:GetPlayerFromCharacter(model) if plr then return plr else return nil end end script.Parent.Touched:Connect(function(hit) -- :connect is deprecated, switch to :Connect player = getPlayerFromCharacter(hit.Parent) if player then if MarketplaceService:UserOwnsGamePassAsync(player.UserId, PassId) then -- if they have the gamepass player.Character:SetPrimaryPartCFrame(pos) else MarketplaceService:PromptGamePassPurchase(player, PassId) -- if they dont teleport them end end end)