Before doing tweens, parent the clone to the correct area so clone.Parent=TextGuiObject
Am I correct that clone is a ui element?
Before doing tweens, parent the clone to the correct area so clone.Parent=TextGuiObject
Am I correct that clone is a ui element?
Ok, but it still gives me the same error.
local textfunction = {}
local text = script.Text.StatusText
local clone = text:Clone()
local value = script.Value.Value
clone.Parent = text.Parent
function textfunction.movetext()
clone.Text = value
clone.TextTransparency = 0
clone:TweenPosition(
UDim2.new(0.25, 0,0.75, 0),
Enum.EasingDirection.Out,
Enum.EasingStyle.Quad,
2,
false
)
wait(1)
clone:TweenPosition(
UDim2.new(0.25, 0,1, 0),
Enum.EasingDirection.In,
Enum.EasingStyle.Quad,
2,
false
)
clone:Destroy()
end
return textfunction
You’re destroying the Clone the moment you call TweenPosition, which is not a yielding function. You need to wait(2) for the tween to finish. TweenPosition() does not yield code, you must yield the code yourself.
nvm Im confused now…
Its inside gui…
It still gives me the same error even though I wait an extra second after the tween is finished.
local textfunction = {}
local text = script.Text.StatusText
local clone = text:Clone()
local value = script.Value.Value
clone.Parent = text.Parent
function textfunction.movetext()
clone.Text = value
clone.TextTransparency = 0
clone:TweenPosition(
UDim2.new(0.25, 0,0.75, 0),
Enum.EasingDirection.Out,
Enum.EasingStyle.Quad,
2,
false
)
wait(3)
clone:TweenPosition(
UDim2.new(0.25, 0,1, 0),
Enum.EasingDirection.In,
Enum.EasingStyle.Quad,
2,
false
)
wait(3)
clone:Destroy()
end
return textfunction
what line does the error lead to?
It leads to line 12, which is
clone:TweenPosition(
Sorry for the late reply but it’s because you’re parenting it to a gui that’s under a script (not under a PlayerGui component, therefore not in a GUI’s “workspace”)
Parent the Clone to a GUI that’s actually under a PlayerGui, it’ll fix your issue.
It doesn’t matter what I did, it just keeps giving me the exact same error.
Maybe try using TweenService on a GUI. It acts similarly to TweenPosition, but it has more feature. Such as ‘Completed’ event, which you can wait for the tween to finish tweening, and delete the clone.
I used TweenService for my XP manager gui, and it worked pretty well.
I hope this helps with your situation. If something is not working, let me know!
It still didn’t work, but at least it gives me a new error.
The error leads to this line from the local script that requires it:
local textfunction = require(textscript)
local player = game.Players.LocalPlayer
local textscript = player.PlayerGui:WaitForChild("Text"):WaitForChild("Text Script")
I think it happens when the ModuleScript errors.
Make sure to do some debugging with prints inside the ModuleScript to determine where and where it doesn’t reach. This will help tremendously.
I realize that there is another error that says, " Unable to cast to Dictionary", and that error leads to this line, I think I am not using the tween correctly.
local uptween = tween:Create(clone,info,up)
(The entire script)
local textfunction = {}
--Variables
local text = script.Parent
local clone = text.StatusText:Clone()
local value = script.Value.Value
local tween = game:GetService("TweenService")
local info = TweenInfo.new(1)
local up = {}
local up = UDim2.new(0.25, 0,0.75, 0)
local down = {}
local down = UDim2.new(0.25, 0,1, 0)
local uptween = tween:Create(clone,info,up)
local downtween = tween:Create(clone,info,down)
--The text function
function textfunction.movetext()
print("The beginning of the function are working")
clone.Text = value
clone.TextTransparency = 0
--Moving the text
uptween:Play()
uptween.Completed:Connect(function()
wait(1)
print("The up tween of the function are working")
downtween:Play()
downtween.Completed:Connect(function()
wait(1)
--Destroy the text so it wouldn't just stay there when it's useless
clone:Destroy()
print("The function is sucessfully done")
end)
end)
end
return textfunction
Try replacing with tween:Create(clone,info,{up})
. Same for the down one.
But that is already in the script
I added one extra thing, which is { }, see closely on the up.
Oh, I added that, but still not working.
I see it now. Try replacing it with tween:Create(clone,info,{Position = up})
, and do the same for the down one.
Thanks, there is no error shown anymore, but the tween is not working for some reason. The tween is supposed to move the text up and then down, but I did not see it move at all. Also, the first few lines that is supposed to change the text transparency and the text, it didn’t.
function textfunction.movetext()
print("The beginning of the function are working")
clone.Text = value
clone.TextTransparency = 0
--Moving the text
uptween:Play()
uptween.Completed:Connect(function()
wait(1)
print("The up tween of the function are working")
downtween:Play()
downtween.Completed:Connect(function()
wait(1)
--Destroy the text so it wouldn't just stay there when it's useless
clone:Destroy()
print("The function is sucessfully done")
end)
end)
end