Hello! So i am trying to make a code so that when the character teleports, their transparency fades out for a few seconds, then comes back. I am trying to tween the players transparency in player visiblity so it smoothly goes from 0-1-0, im super new to coding so bare with me. I want it to be connected to the teleport function like the other tweens so when you press the keybind it all happens at once, any help on what im doing wrong? or what i should do? Please and thank you! I've been looking all day. (note i just cut off the other codes for the tweens, i just copied the player visiblity cause its what im struggling with)
```~~~~~~~~~~~~~~~~~
-- PLAYER VISIBLITY -- local player = game:GetService("Players").LocalPlayer local char = player.Character local children = char:GetChildren() local trtweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut) local trtween = game:GetService("TweenService") for i, child in ipairs(children) do if child:IsA("BasePart") or child:IsA("MeshPart") then if child.Transparency == 0 then trtween:Create(child, trtweenInfo, {Transparency = 1,0}):Play() end end end -- TELEPORTATION -- these can be used on their owns individually wait() local Player = game:GetService("Players").LocalPlayer local Mouse = Player:GetMouse() local Range = 300 Mouse.KeyDown:Connect(function(key) local MousePosition = Mouse.Hit.Position local Distance = (Player.Character.Head.Position - MousePosition).Magnitude if key == "t" and Distance <= Range then print("T was pressed") Tween:Play() TweenLight:Play() wait(1) Player.Character:MoveTo(MousePosition) Regular:Play() TweenLightDef:Play() end end)
~~~~~~~~~~~~~~~~~ ```
To use TweenService, you only put one goal value for each property that you are tweening, and for Transparency
, that would only be one number, not two. So, you should put:
trtween:Create(child, trtweenInfo, {Transparency = 1}):Play()
Since you have set Enum.EasingDirection
to InOut
, it will go from 0 to 1 and back to 0, like you want it to.