I tried to tween a union, but I got the following error.
12:18:47.017 TweenService:Create property named 'CFrame' cannot be tweened due to type mismatch (property is a 'CoordinateFrame', but given type is 'Instance') - Server - teleportScript:58
I have tweened unions using Cframe
before but its not working.
Here is my code:
local number = script.Parent:WaitForChild("Number")
local pad = script.Parent
local bus = workspace:WaitForChild("Bus" .. tostring(number.Value))
local numberOfPlayersInBus = bus:WaitForChild("PlayersInside")
local numberOfSeats = bus:WaitForChild("NumberOfSeats")
local debounce = false
pad.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and not debounce then
debounce = true
local character = player.Character or player.CharacterAdded:Wait()
if character then
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
if humanoidRootPart then
--check for a free seat in the bus
numberOfPlayersInBus = bus:WaitForChild("PlayersInside")
numberOfSeats = bus:WaitForChild("NumberOfSeats")
if numberOfPlayersInBus and numberOfPlayersInBus.Value < numberOfSeats.Value then
-- teleport them inside the bus
local teleport = bus:WaitForChild("teleport")
if teleport then
humanoidRootPart.CFrame = teleport.CFrame
--increase the players in bus
numberOfPlayersInBus.Value += 1
wait(0.5)
debounce = false
end
end
end
end
end
end)
--update the GUI's
script.Parent.Status.Players.Text = tostring("Players " .. numberOfPlayersInBus.Value .. "/" .. numberOfSeats.Value)
numberOfPlayersInBus.Changed:Connect(function()
script.Parent.Status.Players.Text = tostring("Players " .. numberOfPlayersInBus.Value .. "/" .. numberOfSeats.Value)
end)
local tweenTime = 10
local tweenService = game:GetService("TweenService")
local info = TweenInfo.new(tweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, true, 0)
local otherCFrame = workspace:WaitForChild("BusPart"..number.Value)
spawn(function()
while wait() do
--wait
for i = 30, 0, -1 do
wait(1)
script.Parent.Status.Time.Text = "Time Left: " .. i .. "s"
end
--drive bus
script.Parent.Status.Time.Text = "Departing..."
local tween = tweenService:Create(bus.Bus, info, {CFrame = otherCFrame.CFrame})
tween:Play()
wait(tweenTime)
end
end)
Where do I supply an Instance instead of a CFrame?