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

2 comments
My best guess is you do {Value = Part.Up.Value}
Still Wont Work