Hello there, I am trying to teleport a player from part A to part B if they touch either part and if they bear the same attributes (location and destination). Here is what I have tried below. The problem is that the tween won’t play. Any takers?
local tweenService = game:GetService('TweenService')
game.Players.PlayerAdded:Connect(function(player)
for _, v in pairs(game.Workspace:GetDescendants()) do
if v.Name == 'Portal' then
local teleportPart = v.Teleport
teleportPart.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local character = player.Character
local location = v:GetAttribute('Location')
local destination = v:GetAttribute('Destination')
for index, value in pairs(game.Workspace:GetDescendants()) do
if value:GetAttribute('Location') == destination then
local tweenInfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In
)
tweenService:Create(character.HumanoidRootPart, tweenInfo, {CFrame = value.Teleport.CFrame})
end
end
end
end)
end
end
end)