Hey Guys. I’m currently trying to get this tween to work where the PortalGuiFrame fades in and then out after entering a portal. For some reason the Tween does not play, and I already checked if the remote event actually works and it does. I’ve tried looking up tutorials to see if I was doing anything wrong but I couldn’t find anything in my code that would make the tween not play. Thanks for the help!
PortalGuiHandle LocalScript
local TweenService = game:GetService("TweenService")
local PortalRemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("Portal")
local PortalGuiFrame = script.Parent
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
true
)
local tween = TweenService:Create(PortalGuiFrame, tweenInfo, {BackgroundTransparency = 0})
PortalRemoteEvent.OnClientEvent:Connect(function()
print("Activated")
PortalGuiFrame.Visible = true
tween:Play()
PortalGuiFrame.Visible = false
end)
object.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit:IsA("Part") then
if PortalDebounce == false then
PortalDebounce = true
local char = hit.Parent
local humanoid = char:WaitForChild("Humanoid")
local humanoidRoot = char:WaitForChild("HumanoidRootPart")
local plr = Players:GetPlayerFromCharacter(char)
PortalRemoteEvent:FireClient(plr)
--Waits until screen is fully covered by effect
wait(1)
humanoidRoot.CFrame = lobby:WaitForChild("Baseplate").CFrame * CFrame.new(0, 7, 0)
--Make sure to add to the player's wins!!!
wait(1.5)
PortalDebounce = false
end
end
end)
I think the tween is playing but it is immediately being changed to invisible, try adding a wait in between the tween and “PortalGuiFrame.Visible = false”
Ediit: Just tested this myself thats not the reason, but why did you set reverse in the tweeninfo to true?
You directly calling PortalGuiFrame.Visible = false before the tween even finished just put tween.Completed:Wait() between tween:Play() and PortalGuiFrame.Visible = false which will look like this
local TweenService = game:GetService("TweenService")
local PortalRemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("Portal")
local PortalGuiFrame = script.Parent
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
true
)
local tween = TweenService:Create(PortalGuiFrame, tweenInfo, {BackgroundTransparency = 0})
PortalRemoteEvent.OnClientEvent:Connect(function()
print("Activated")
PortalGuiFrame.Visible = true
tween:Play()
tween.Completed:Wait()
PortalGuiFrame.Visible = false
end)