this is the code that shows the error
game.TweenService:Create(hand,TweenInfo.new(TweenDelay),{CFrame * CFrame.new(pos, Direction) * CFrame.Angles(math.rad(90),0,0)}):Play()
this is the code that shows the error
game.TweenService:Create(hand,TweenInfo.new(TweenDelay),{CFrame * CFrame.new(pos, Direction) * CFrame.Angles(math.rad(90),0,0)}):Play()
You are embedding the CFrame data into a table. Simply remove the CFrame from the table.
Here is your corrected code:
game.TweenService:Create(hand,TweenInfo.new(TweenDelay),CFrame * CFrame.new(pos, Direction) * CFrame.Angles(math.rad(90),0,0)):Play()
still showing
invalid argument #1 (CFrame expected, got table)
in the output
Ah I missed it. You are multiplying CFrame
(which is a table) by CFrame.new
(which returns a numeric value).
Here is your fixed code:
game.TweenService:Create(hand,TweenInfo.new(TweenDelay),CFrame.new(pos, Direction) * CFrame.Angles(math.rad(90),0,0)):Play()
for some reason it shows
Unable to cast to Dictionary
Is this error occurring on the same line?
yes its in the same line
11:41:08.572 Unable to cast to Dictionary - Server - Script:28
No this is the incorrect way to use TweenService:Create()
.
The third argument of :Create()
expects a dictionary where the key is the property of the object you’re tweening and the value is the goal. What you’re trying to do should be done as such:
local TweenService = game:GetService('TweenService')
TweenService:Create(
hand,
TweenInfo.new(TweenDelay),
{
CFrame = CFrame * CFrame.new(pos, Direction) * CFrame.Angles(math.rad(90),0,0)
}
):Play()
Oh I didn’t think to look at TweenService API. Good job.
Number on the left is line number
29 TweenService:Create(
30 hand,
31 TweenInfo.new(TweenDelay),
32 {
33 CFrame = CFrame * CFrame.new(pos, Direction) * CFrame.Angles(math.rad(90),0,0)
34 }
35 ):Play()
Workspace.Dummy.Script:33: invalid argument #1 (CFrame expected, got table)
What is your CFrame
variable?
That was what I mentioned before. I believe he is trying to reference to the CFrame of the object he is tweening. Can’t really help if we don’t have that info though.
local TweenService = game:GetService('TweenService')
function lerp(a, b, c)
return a + (b - a) * c
end
function quadBezier(t, p0, p1, p2)
local l1 = lerp(p0, p1, t)
local l2 = lerp(p1, p2, t)
local quad = lerp(l1, l2, t)
return quad
end
while true do
local hand = script.Parent["Left Arm"]:Clone()
hand.Parent = workspace
hand.Anchored = true
hand.CanCollide = false
local p0 = script.Parent.HumanoidRootPart
local p1 = script.Parent.HumanoidRootPart.Position + Vector3.new(math.random(-10,10),math.random(-1,1),0)
local p2 = script.Parent.HumanoidRootPart.Position + Vector3.new(0,0,-6)
local TweenDelay = wait()
game.Debris:AddItem(hand,.1)
game.TweenService:Create(hand,TweenInfo.new(1),{Transparency = 1}):Play()
for i = 1, 10 do
local t = i/10
local pos = quadBezier(t, p0.Position, p1, p2)
local Direction = quadBezier(t + 0.005, p0.Position,p1, p2)
--hand.CFrame = CFrame.new(pos,Direction)
TweenService:Create(
hand,
TweenInfo.new(TweenDelay),
{
CFrame = CFrame * CFrame.new(pos, Direction) * CFrame.Angles(math.rad(90),0,0)
}
):Play()
wait()
end
end
the whole script maybe u can find problem from it
there’s no CFrame
variable anywhere but you’re trying to multiply it?
oh wait is just me forgot to add CFrame = CFrame.new()
in game.TweenService:Create(hand,TweenInfo.new(TweenDelay),CFrame * CFrame.new(pos, Direction) * CFrame.Angles(math.rad(90),0,0)):Play()
also thanks for trying to help me find out the problem
Yeah, whatever properties you intend to tween need to be added as keys/fields to the tween’s goal dictionary.