Frame tween not working

Im trying to make that when i click on a button it fades out.
Nothing happens when i try to click on the button, but when i put my tween outside MouseButton1Click then it works

my script:

local player = game.Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")

script.Parent.Back.MouseButton1Click:Connect(function()
	local FadeFrame = PlayerGui.Customization:WaitForChild("FadeFrame")
	local tweenService = game:GetService("TweenService")
	local tweeninfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true, 0)
	local tween1 = tweenService:Create(FadeFrame, tweeninfo, {BackgroundTransparency=0})
	
	wait(0.1)
	tween1:Play()
	
	game.ReplicatedStorage.Customization.UpdateClothing:FireServer(dummy.Shirt.ShirtTemplate,dummy.Pants.PantsTemplate)
	script.Parent.Enabled = false
	cam.CameraType = Enum.CameraType.Custom
end)
1 Like

Use MouseButton1Down instead, MouseButton1Click has some limitations and is only recommended for mobile.

I tried it but it’s still not working

You can also use Activated, it works for all platforms

What object is script.Parent.Back?

I think its a button that closes a frame with a tween animation

Just to make sure whether its a button object

try Activated for the button event, but honestly everything else looks fine to me. try putting prints in the event to see where it doesn’t work or do script.Parent:WaitForChild(“Back”)

local player = game.Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local function tween(obj,value)
	local tweenService = game:GetService("TweenService")
	local tweeninfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true, 0)
	local tween1 = tweenService:Create(obj, tweeninfo, {BackgroundTransparency = value})
	tween1:Play()
end

script.Parent.Back.MouseButton1Click:Connect(function()
	local FadeFrame = PlayerGui.Customization:WaitForChild("FadeFrame")
	wait(0.1)
	tween(FadeFrame,0)
	game.ReplicatedStorage.Customization.UpdateClothing:FireServer(dummy.Shirt.ShirtTemplate,dummy.Pants.PantsTemplate)
	script.Parent.Enabled = false
	cam.CameraType = Enum.CameraType.Custom
end)

its a TextButton to finish your character creation

@fun_tijger

There is still no tween happening

can u try adding print to see where it gets stuck at

i added two prints and they both worked

local function tween(obj,value)
	local tweenService = game:GetService("TweenService")
	local tweeninfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true, 0)
	local tween1 = tweenService:Create(obj, tweeninfo, {BackgroundTransparency = value})
	tween1:Play()
	print("tweenfunction")
end

script.Parent.Back.MouseButton1Click:Connect(function()
	local FadeFrame = PlayerGui.Customization:WaitForChild("FadeFrame")
	wait(0.1)
	print("tweenplay")
	tween(FadeFrame,0)
	game.ReplicatedStorage.Customization.UpdateClothing:FireServer(dummy.Shirt.ShirtTemplate,dummy.Pants.PantsTemplate)
	script.Parent.Enabled = false
	cam.CameraType = Enum.CameraType.Custom
end)

what type of script are u using?

Where’s the camera at? That may be your problem, you could also set it to Enum.CameraType.Scriptable then to Enum.CameraType.Custom

im using a localscript (3O charrrrr)

It was already set to scriptable because the script is for character customization and then after the tween the cameratype is set to custom.

I think I know. Try setting this 0 in tween(fadeframe) to 1

I can’t really tell what’s wrong with the script if I can’t see the variables.