I am attempting to make a VIP tp script, so that when a player with VIP touches the door, it will tp them to the position of the VIP room. Though this does not work, all it does is print out, 'Not a valid Player' on line 6.
Here is my script:
local gamepassId = 1109268370 function onTouch(hit) local player = hit.Parent local torso = player:FindFirstChild("Torso") if game:GetService("GamePassService"):PlayerHasPass(player, gamepassId) then torso.CFrame = CFrame.new(script.Parent.Parent.VIPPlatform.Position) wait() else return false end end script.Parent.Touched:Connect(onTouch)
Any help is appreciated, thanks.
When a player Touches something, it returns the character and not the player object. PlayerHasPass
is looking for the player object, not a model in Workspace. :P
local gamepassId = 1109268370 function onTouch(hit) local character = hit.Parent local player = game.Players:GetPlayerFromCharacter(hit.Parent) local torso = character:FindFirstChild("Torso") --EDIT: changed the variable used to character instead of player if game:GetService("GamePassService"):PlayerHasPass(player, gamepassId) then torso.CFrame = CFrame.new(script.Parent.Parent.VIPPlatform.Position) wait() else return false end end script.Parent.Touched:Connect(onTouch)