Problem with color tweening

I want to make an exit for a Horror game me and my friend are working on. I want there to be a white screen that changes to a black screen and then makes text appear when exiting.

I tried to tween the colors from going white to black witch was the problem. The output box says: ‘‘Unable to cast to dictionary’’ I have no idea what that means, but basically it made the white screen pop up but it didn’t change to black after a few seconds.

This is the script:

local part = script.Parent

local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1)

local Light = game.StarterGui.ExitGUI.Light

local goal = {}
goal = Light.BackgroundColor3 == Color3.new(0)

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)

		if player then
			if not player.PlayerGui.ExitGUI.Light.Visible then
				player.PlayerGui.ExitGUI.Light.Visible = true
				local tween = TweenService:Create(Light, tweenInfo, goal)
				tween:Play()
			end
		end
	end
end)

I had just gotten into working with TweenService so I’m pretty new to it and would like to know more about it. I had one success with it by smoothly rotating and moving objects when clicked.

Your goal properties are formatted incorrectly.
They want to look like this:

local goal = {
   NameOfProperty = newValueForPropertyToTweenTo,
   BackGroundColor = Color3.new(0,0,0)  --For example (excuse the capitalisation)
}

So long as the property is a valid property of the element being tweened, and is tween-able, you can add as many property = value pairs as required. Just bear in mind they will all run at the same speed as in your tweenInfo.

1 Like

I’m confused, I should add an IntValue to the script?

I’m not sure what you mean?
The format required for the tween’s property table is as shown in my previous post.
An IntValue is a specific Instance type holding data of type ‘Int’ (a number basically).