I tried condensing three functions that were built just for a certain value to tween into one. When sending over a string for valtype the script doesn’t recognize the string and only considers the property needing changing to be “valtype”
--made by the one and only marfit
local TweenService = game:GetService("TweenService")
local transitiongui = script.GUIs.Transition
local module = {}
function module.Transition(from,to)
transitiongui.Parent = script.Parent.Parent.PlayerGui
module.Tween(transitiongui,"BackgroundTransparency",0,Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.7)
wait(0.71)
from.Parent = script.GUIs
wait(1)
if to == 0 then
module.Tween(transitiongui,"BackgroundTransparency",1,Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.7)
end
transitiongui.Parent = script.GUIs
end
function module.Tween(gui,valtype,val,easedirection,easestyle,length)
local goals = {
valtype = val
}
local info = TweenInfo.new(
length,
easestyle,
easedirection
)
local tween = TweenService:Create(gui,info,goals)
tween:Play()
end
return module```
Any help?
It seems like you set it to whatever is passed into val. Perhaps when you merged the functions you changed the function arguments and one of the spots calling it wasn’t changed to use the new version of the function.
It is hard to know anything for sure because these functions use values and variable from many places and we don’t see what manipulates them and what type of values they are. (A type system would be helpful here, or more code)
I’m not sure I understand. That is ALL the code. The only other code in my game is an FPS counter and a LocalScript that calls Transition with the arguments being the ImageButton that is parent of the LocalScript and 0.
Wouldn’t it just make more sense to do the Tween function like so?
function module.Tween(Object, Length, Style, Direction, Properties)
TweenService:Create(
Object,
TweenInfo.new(Length, Enum.EasingStyle[Style].Value, Enum.EasingDirection[Direction].Value),
Properties
):Play()
end
Then it can be just called like module.Tween(Frame, 1, "Quint", "Out", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.new(0.5, 0, 0.5, 0) }), which is a lot easier.
No, it doesn’t work, just gives me a code error “Expected identifier” I misread your instructions. It works! Thank you very much. Nevermind…The tween doesn’t play for some reason??
I had set the BackgroundTransparency to 0 when it was supposed to be 1.