Script Inside Spike Trap Model
local Spikes = {} local Model = script.Parent local Base = Model.Base local TweenService = game:GetService("TweenService") local CanSpike = true for i,v in pairs(Model:GetChildren()) do if v:IsA("BasePart") then if v.Name == "Spike" or v.Name ~= "Base" then table.insert(Spikes,v) end end end repeat wait() until table.getn(Spikes) ~= 0 function createTweeningValues(Part) local UpCFrame = Instance.new("CFrameValue") local DownCFrame = Instance.new("CFrameValue") UpCFrame.Name = "Up" DownCFrame.Name = "Down" UpCFrame.Parent = Part DownCFrame.Parent = Part UpCFrame.Value = CFrame.new(Part.CFrame.X,Part.CFrame.Z+Part.Size.Z,Part.CFrame.Y) DownCFrame.Value = CFrame.new(Part.CFrame.X,Part.CFrame.Z-Part.Size.Z,Part.CFrame.Y) end function tween(Part) local Twn = TweenService:Create(Part,TweenInfo.new(2),Part.Up.Value) Twn:Play() wait(2) local Twn2 = TweenService:Create(Part,TweenInfo.new(2),Part.Down.Value) Twn2:Play() end for _,Spike in pairs(Spikes) do createTweeningValues(Spike) end Base.Touched:Connect(function(hit) local Par = hit.Parent local Player = game.Players:GetPlayerFromCharacter(Par) if Player and CanSpike then CanSpike = false for _,Spike in pairs(Spikes) do tween(Spike) end wait(5) CanSpike = true end end)
Error
22:53:02.361 - Unable to cast to Dictionary
22:53:02.361 - Stack Begin
22:53:02.361 - Script 'Workspace.SpikeTrap.Script', Line 34 - global tween
22:53:02.362 - Script 'Workspace.SpikeTrap.Script', Line 49
22:53:02.362 - Stack End
What they mean by dictionary is that the last argument of Create needs to be like a table of things to tween, e.g
local Twn = TweenService:Create(Part,TweenInfo.new(2),{CFrame = CFrame.new(1,1,1)})
and "Value" cant be tweened, the properties that can be tweened and can be included in the dictionary are:
number
bool
CFrame
Rect
Color3
UDim
UDim2
Vector2
Vector2int16
Vector3
I think your Up.Value is vector3 right? so just include the Up.Value in the CFrame constructor