Hi there! I’m not going to introduce myself and get straight to the point. Basically, I want to make a Gamepass teleporter, so if you own a gamepass and touch the teleporter brick, you get teleported. Now matter what I try it never works, whether it be free models or tutorials. Could anyone help me with this?
Additional information:
I have my two teleporters in one model.
The gamepass ID is 11173507 (And I own it).
If you need any more info, please ask.
Thank you. I have been testing and nothing is working yet again, this is what I put in a local script inside of the teleporter brick. I am not attempting teleporting just yet just so I can make sure the script does work.
local player = game.Players.LocalPlayer
script.Parent.Touched:Connect(function()
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 11173507) then
print("Owns Gamepass!")
end
end)
You need to make a script, as you want it to be server-sided, and it won’t function as you desire with the localscript. So what I’m stating is, you’d need to use a script rather than a localscript.
local player = game.Players.LocalPlayer
script.Parent.Touched:Connect(function()
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 11173507) then
print("Owns Gamepass!")
end
end)
and got this error:
Workspace.Teleports.tele1.Script:4: attempt to index nil with ‘UserId’
I’m not sure what happened here?
On short u should move the code into server script:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(hit.Parent.UserId, 11173507) then
print("Owns Gamepass!")
end
end
end)
You can’t use game.Players.LocalPlayer in scripts, only in localscripts. If you’re configuring a script and want to manage the player, you’d use game.Players.PlayerAdded:Connect(function(plr). Since you’re making a touch brick, I’d recommend using @nuttela_for1me’s code, as you’d only get that player from the character that hit the object.
Awesome! Managed to figure it out, thanks so much for the help <3
I love the devforum so much, everyone is so kind and smart and help a lot, I appreciate this so much because my dumb self wouldve taken a week to figure this out hahah
local Gamepass = 11173507
local Place = 00000 -- Place ID
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(hit.Parent.UserId, Gamepass) then
print("Owns Gamepass!")
game:GetService("TeleportService"):Teleport(Place, hit.Parent)
end
end
end)