Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Unable to Cast to Dictionary when Tweening?

game.ReplicatedStorage.Arrest.OnServerEvent:Connect(function(arrestee)
	if arrestee["TeamColor"] == BrickColor.new("Really blue") or arrestee["Settings"].innocent.Value == true then
		print("innocent")
	else
		arrestee.Settings.innocent.Value = true
		local arrested = arrestee.Character
		local humanoid = arrested["Humanoid"]
		local prisoncell = prisoncells[math.random(#prisoncells)]
		local cell = prisoncell["cell"]
		local cellpos = cell.CFrame
		local prisondoor = prisoncell["Door"]
		local TweenService = game:GetService("TweenService")
		local tweenInfo = TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
		local DoorOpen = {CFrame = -88.09, 6.402, -2.506 }
		local DoorClose = {CFrame = -82.052, 6.402, -2.506 }
		local Open = TweenService:Create(prisondoor,tweenInfo,DoorOpen)
		local Close = TweenService:Create(prisondoor,tweenInfo,DoorClose)
		Close:Play()
		wait(10)
		Open:Play()
		local AnimTrack = humanoid:LoadAnimation(Anim)
		AnimTrack:Play()
		humanoid["WalkSpeed"] = 0
		wait(5)
		arrestee["TeamColor"] = BrickColor.new("Deep orange")
		humanoid["WalkSpeed"] = 14
		arrested["HumanoidRootPart"].CFrame = cellpos
	end
end)

This is almost the whole script the error is on lines 16-17

1 comment

0

what is the actual error code pls :(

2 answers

✓ Accepted answer

The problem here is that your variables DoorOpen and DoorClose are not set up correctly. You have them as dictionaries which is correct, but you are defining the CFrame incorrectly. CFrame is a Vector3 value.

Inside your dictionary your key (in our case CFrame) should be equal to a Vector3 (aka your value).

local doorOpen = {CFrame = CFrame.new(0, 0, 0)}
-- Subsitute your numbers for the 0, 0, 0

1 comment

0

yeah I figured that out 1 week ago thx for your help

The problem is that you do not use numbers with CFrame, you use CFrame.new() like so:

local doorOpen = {CFrame = CFrame.new(-88.09, 6.402, -2.506)}
local doorClose = {CFrame = CFrame.new(-82.052, 6.402, -2.506)}

This discussion is preserved as it was. New answers, comments, and votes are closed.