You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I created a Module Script containing a function that does tweening and I want to use tween.Completed for another script. For example when the tween is finished, I want to delete a BasePart when the transparency gets to 1. -
What is the issue? Include screenshots / videos if possible!
I am unsure on how I can achieve this. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Well I could just copy the code from the module script and move it to where I need too, but It would also be great if there was a better solution.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Just incase here is the tween function
local module = {}
local tweenService = game:GetService("TweenService")
module.TweenFadeTransparency = function(ObjToTween)
local timeToFade = 1
local object = ObjToTween
local tweenInfo = TweenInfo.new(timeToFade)
local goal = {}
if ObjToTween:IsA("TextLabel") then
goal.BackgroundTransparency = 1
goal.TextTransparency = 1
elseif ObjToTween:IsA("Frame") then
goal.BackgroundTransparency = 1
elseif ObjToTween:IsA("BasePart") then
goal.Transparency = 1
end
local tween = tweenService:Create(object, tweenInfo, goal)
tween:Play()
tween.Completed:Connect()
end
return module
and here is when I want to use the tween.Completed
function GameEnded()
print("Intermission!")
for i = IntermissionTime, 0, -1 do
TimerEvent:FireAllClients(i)
if i == IntermissionTime * 0.5 then
print(i)
FadeEvent:FireAllClients(game.Workspace.CurrentMap:FindFirstChild(script.ChosenMap.Value))
DeleteMap()
end
wait(1)
end
end
I forgot that the module script function I made is being used on a Local Script, which should fire an event to the server so it can run the DeleteMap function. Its really confusing now that I think about it
local FadeEvent = game.ReplicatedStorage.RemoteEvents.FadeEvent
local TweenFunctions = require(game.ReplicatedStorage.TweenFunctions)
local tween = TweenFunctions.TweenFadeTransparency()
FadeEvent.OnClientEvent:Connect(function(TableToUse)
print(TableToUse:GetChildren())
for i, v in pairs(TableToUse:GetChildren()) do
if v:IsA("Model") then
for i,v2 in pairs(v:GetChildren()) do
if v2:IsA("BasePart") then
TweenFunctions.TweenFadeTransparency(v2)
end
end
end
if v:IsA("BasePart") then
TweenFunctions.TweenFadeTransparency(v)
end
end
end)
So in summary, I made a tween inside a module script, I then want to use this tween inside a Local Script. Then with that I want to use the tween.Completed on a Server Script to delete parts.
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.