It gives a Unable to cast to dictionary error on the 8th line
local Emerald = script.Parent
local text = game.StarterGui.GemFounded:WaitForChild('GemFoundedText')
local GameStarted = script.Parent:FindFirstChild('GameStarted')
local TS = game:GetService('TweenService')
local TI = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0)
local textTween = TS:Create(text, TI, {Position = 0.5, 0, 0.091, 0});
Emerald.Touched:Once(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and GameStarted.Value == true and text.Position == CFrame.new(0.5, 0, -0.051, 0) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local username = player.Name
text.Text = 'Emerald has been found by'.. username .. '!'
textTween:Play()
else
warn('Bişey yanlış gitti')
end
end
end)
The issue is that the position in 3D space must be Vector3
Here is corrected script:
local Emerald = script.Parent
local text = game.StarterGui.GemFounded:WaitForChild('GemFoundedText')
local GameStarted = script.Parent:FindFirstChild('GameStarted')
local TS = game:GetService('TweenService')
local TI = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0)
local textTween = TS:Create(text, TI, {Position = Vector3.new(0.5, 0, 0.091, 0)}); -- Position in 3D space must be Vector3
Emerald.Touched:Once(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and GameStarted.Value == true and text.Position == CFrame.new(0.5, 0, -0.051, 0) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local username = player.Name
text.Text = 'Emerald has been found by'.. username .. '!'
textTween:Play()
else
warn('Bişey yanlış gitti')
end
end
end)
TweenService:Create property named 'Position' cannot be tweened due to type mismatch (property is a 'UDim2', but given type is 'Vector3') - Server - TextSystem:8
local Emerald = script.Parent
local text = game.StarterGui.GemFounded:WaitForChild('GemFoundedText')
local GameStarted = script.Parent:FindFirstChild('GameStarted')
local TS = game:GetService('TweenService')
local TI = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0)
local textTween = TS:Create(text, TI, {Position = UDim2.new(0.5, 0, 0.091, 0)}); -- 2d space :)
Emerald.Touched:Once(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and GameStarted.Value == true and text.Position == CFrame.new(0.5, 0, -0.051, 0) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local username = player.Name
text.Text = 'Emerald has been found by'.. username .. '!'
textTween:Play()
else
warn('Bişey yanlış gitti')
end
end
end)
Just founded another issue where text label position is set to CFrame
Here is corrected script
local Emerald = script.Parent
local text = game.StarterGui.GemFounded:WaitForChild('GemFoundedText')
local GameStarted = script.Parent:FindFirstChild('GameStarted')
local TS = game:GetService('TweenService')
local TI = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0)
local textTween = TS:Create(text, TI, {Position = UDim2.new(0.5, 0, 0.091, 0)}); -- 2d space :)
Emerald.Touched:Once(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and GameStarted.Value == true and text.Position == UDim2.new(0.5, 0, -0.051, 0) then -- CFrame -> Udim2
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local username = player.Name
text.Text = 'Emerald has been found by'.. username .. '!'
textTween:Play()
else
warn('Bişey yanlış gitti')
end
end
end)
Hello,
I just wanted to inform you that tweens don’t work for text like that
In order to tween a GUI ASSET you need to -
Gui:TweenPosition(...) -- changes position
Gui:TweenSize(...) -- changes size
Gui:TweenSizeAndPosition(...) -- changes both size and position
-- specify parameters accordingly
Nope its not right. It is not decaperated and If i am wrong about this show me how to do it please.
and I find the only way to tween the UI’s Size and Position is this
yes it is bro, you can’t just dismiss something without fact checking, as @SeargentAUS already said, there is a big red box, with nice letters stating: “Deprecated”.
edit: I realised my response might come off as offensive, I am sorry if this offends you.
No issues it wasn’t offensive.
I was just quite outdated on this topic of TweenService.
During the time I learned it about this, we couldn’t use TweenService to tween the position at those times. I remember struggling to find out that it wouldn’t work.
The only reason I see to this for a dictionary error is the {Position = 0.5, 0, 0.091, 0}
The solution to this is -
local Emerald = script.Parent
local text = game.StarterGui.GemFounded:WaitForChild('GemFoundedText')
local GameStarted = script.Parent:FindFirstChild('GameStarted')
local TS = game:GetService('TweenService')
local TI = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0)
local textTween = TS:Create(text, TI, {Position = UDim2.new(0.5, 0, 0.091, 0)});
Emerald.Touched:Once(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and GameStarted.Value == true and text.Position == CFrame.new(0.5, 0, -0.051, 0) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local username = player.Name
text.Text = 'Emerald has been found by'.. username .. '!'
textTween:Play()
else
warn('Bişey yanlış gitti')
end
end
end)