#unable to cast to dictionary

31 messages · Page 1 of 1 (latest)

robust cargo
#

im making a day night cycle and im making an animation for a textlabel
script:

game.Players.LocalPlayer.PlayerScripts.hello.Sound.Played:Connect(function()
    script.Parent.Value.Value += 1
    
    script.Parent.Text = "DAY "..script.Parent.Value.Value
    
    local tweenservice = game:GetService("TweenService")

    local twoon = game.Lighting

    local goals = {Position = {0.445, 0},{0.04, 0}, TextSize = 32, TextTransparency = 0}

    local info = TweenInfo.new(
        300, 
        Enum.EasingStyle.Linear,
        Enum.EasingDirection.Out,
        0,
        false,
        0
    )
    local tween = tweenservice:Create(twoon, info, goals)
    
end)
haughty niche
#

There are a few issues with this script.

game.Players.LocalPlayer.PlayerScripts.hello.Sound.Played appears to be a reference to a non-existent object. It's possible that it's a typo, but it's hard to say for certain without more context.

script.Parent.Value.Value is being incremented by 1, but it's unclear where Value is being defined or where it's coming from.

local tween = tweenservice:Create(twoon, info, goals) appears to be creating a Tween with an invalid target (twoon) and goals (goals)

The "goals" position properties are not right. it should be Position = Vector3.new(0.445, 0,0.04)

script.Parent.Text = "DAY "..script.Parent.Value.Value is setting the value of Text without a proper context, it's not clear what is being referred to.

there is no invocation of the function, the function should be invoked at some point, otherwise it will not be executed.

So to sum up, the script is not properly referencing objects, incrementing values, and has invalid Tween goals and target. Without more context it's hard to say what this script is trying to do, it seems that it is trying to do different things, you may need to revise the script and better understand what you want to achieve with the script.

#

i can make a script for you if you want

robust cargo
#

jeez you only had to tell me this part:

The "goals" position properties are not right. it should be Position = Vector3.new(0.445, 0,0.04)
haughty niche
#

tell me if that works if not i aready fully rewrote a code that should work

#

ill just send it anyways

#

In the Script object, add the following code to create a day-night cycle:

Copy code
local DayLength = 10 --length of day in minutes
local NightLength = 10 --length of night in minutes
local DayNightRatio = DayLength/(DayLength + NightLength) --ratio of day to night

while true do
--set Lighting to daytime
game.Lighting.TimeOfDay = DayNightRatio
wait(DayLength60)
--set Lighting to nighttime
game.Lighting.TimeOfDay = 1-DayNightRatio
wait(NightLength
60)
end

robust cargo
#

also the game.lighting thing was just a thing cause i copied another another script and i forgot to change it before sending it here

haughty niche
#

local TextLabel = game.Workspace:WaitForChild("TextLabel")
local TweenService = game:GetService("TweenService")

while true do
-- Get the current time of day and update the TextLabel
local timeOfDay = game.Lighting.TimeOfDay
if timeOfDay < DayNightRatio then
TextLabel.Text = "Day"
else
TextLabel.Text = "Night"
end

-- animate the TextLabel
local goal = { TextTransparency = 0 }
local info = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local tween = TweenService:Create(TextLabel, info, goal)
tween:Play()
wait(1)

end
This script will create a day night cycle of 10 minutes of day and 10 minutes of night. It will update the game.Lighting.TimeOfDay based on the ratio of day and night. Also, it will update the text of the TextLabel and animate it. As you could notice, you can play with the values for DayLength and NightLength to achieve the desired effect.

You could also take advantage of the ParticleEmitter and other effects that are possible in Roblox to improve the visual representation of the day-night cycle.

robust cargo
#

bro

#

i only asked why i got the error unable to cast to dictionary

#

u didnt have to do all this lol

haughty niche
#

ooooh

#

its nothing tho

#

lmk if you need help with anything else

robust cargo
#

uhhh ok

haughty niche
#

what code do you need next

#

i could make it for you

robust cargo
#

i got this error

shadow wedgeBOT
#

studio** You are now Level 3! **studio

robust cargo
#

TweenService:Create property named 'Position' cannot be tweened due to type mismatch (property is a 'UDim2', but given type is 'Vector3')

haughty niche
#

ohhh

#

The error message "TweenService:Create property named 'Position' cannot be tweened due to type mismatch (property is a 'UDim2', but given type is 'Vector3')" is indicating that the Position property of the twoon object is of type UDim2, but you are trying to set it to a Vector3 value.

UDim2 is a type that describes the position and size of a GUI element in terms of pixels and a scale. In other words, it is used to layout UI element, where as Vector3 is used to represent a point or a direction in a 3D coordinate system.

In order to animate the lighting in a way that makes sense, you would need to change the value of the properties Brightness or OutdoorAmbient that are related to lighting properties.

You should also update the Goals property so it fits the properties of the twoon object, which is game.Lighting, for example:

#

game.Players.LocalPlayer.PlayerScripts.hello.Sound.Played:Connect(function()
script.Parent.Value.Value += 1
script.Parent.Text = "DAY "..script.Parent.Value.Value

local tweenservice = game:GetService("TweenService")
local lighting = game.Lighting
local textLabel = script.Parent:WaitForChild("TextLabel")

-- Animate the lighting
local goals = {Brightness = 0.5}
local info = TweenInfo.new(300, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local tween = tweenservice:Create(lighting, info, goals)
tween:Play()

-- Update the TextLabel
textLabel.Text = "Day "..script.Parent.Value.Value
textLabel.TextTransparency = 0

end)
This code connects to a "Played" event on a sound, which increases the value of script.Parent.Value by 1, and updates the text of the TextLabel with "DAY " followed by the value of script.Parent.Value. Then, it creates a tween that changes the brightness of the lighting to 0.5 in 300 seconds using a linear easing style. Finally, it sets the TextTransparency of the textlabel to 0.

Keep in mind that this code assumes that you have correctly referenced the objects you are trying to interact with, such as 'TextLabel' and 'hello' (the sound), and also you may need to adjust the values according to your desired effect.

#

lmk if that works

robust cargo
#

this is the code i have right now just so you know cause you're still going off the old script but the problem im having now is that the text isnt moving when the function activates

game.Players.LocalPlayer.PlayerScripts.hello.Sound.Played:Connect(function()
script.Parent.Value.Value += 1

script.Parent.Text = "DAY "..script.Parent.Value.Value

local tweenservice = game:GetService("TweenService")

local twoon = script.Parent

local goals = {Position = UDim2.new(0,445, 0,0.124), TextSize = 32, TextTransparency = 0}

local info = TweenInfo.new(
    1, 
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local tween = tweenservice:Create(twoon, info, goals)

end)

haughty niche
#

oooooooh

#

ik see the problem

#

game.Players.LocalPlayer.PlayerScripts.hello.Sound.Played:Connect(function()
local textLabel = script.Parent
textLabel.Value.Value += 1
textLabel.Text = "DAY "..textLabel.Value.Value
local tweenService = game:GetService("TweenService")

-- Goals for the animation
local goals = {TextSize = 32, TextTransparency = 0}

-- Tween Info
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local tween = tweenService:Create(textLabel, info, goals)
tween:Play()

end)
This script connects to the "Played" event of a sound, and increases the Value property of the textLabel by 1. The script also updates the text of the label to say "DAY " followed by the value of Value. Then, it creates a Tween that changes the TextSize to 32, and TextTransparency to 0 of the TextLabel over 1 seconds. Finally, it invokes tween:Play() to play the animation, this will make the text bigger and become visible in case it was transparent before.

As always, make sure that you are correctly referencing the objects you want to interact with and adjust the values according to your desired effect.

#

i have to go know

#

GL