Hi everyone. So im working on a script that when you touch a button, a door opens and then a neon part in replicated storage comes on the position of the door and when u touch that neon part, it teleports you to a place. What i want to add is, a fading gui appears while you teleporting to the place. I tried 2 ways; first was doing it with for loop, but it worked with problem. Second one was doing with tweenService and it didnt even do anything. Here s the script (its in starterGui, i want it to only do on client);
local tweenserv = game:GetService("TweenService")
game.ReplicatedStorage.RedDoorEvent.OnClientEvent:Connect(function()
game.ReplicatedStorage.TpRedDoor.Parent = game.Workspace
game.Workspace.RedDoorButton.Position = game.Workspace.RedDoorButton.Position - Vector3.new(0.3, 0, 0)
game.Workspace.RedDoorButton.Script.Enabled = false
local redDoor = game.Workspace.RedDoor
task.spawn(function() -- this is multi threading allows you to run code concurrently, well i think roblox mimics it or thats python? idk, but anyways we dont want the stuff below it to wait right? so we make it run concurrent with them by giving it a new thread to run off of
for i,v in pairs(redDoor:GetDescendants()) do
if v:IsA("BasePart") then -- we can check what class the Parent of the part that touched this part is then then
task.spawn(function()
tweenserv:Create(v, TweenInfo.new(1.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {Transparency = 1}):Play()
end)
end
if v:IsA("BasePart") then-- basepart class is a superclass it refers to every part class, classes have a superclass that they are a child of, meshparts any type of parts are baseparts just like how module scripts, scripts and localscripts are all under the superclass BaseScript
task.spawn(function()
tweenserv:Create(v, TweenInfo.new(1.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {Transparency = 1}):Play()
end)
end
end
wait(1.6)
redDoor:Destroy()
local tpRedDoor = game.Workspace:FindFirstChild("TpRedDoor") -- tip if your not doing a check use [""] for faster index or .name but it doesnt matter
local tweenserv = game:GetService("TweenService")
tpRedDoor.Touched:Connect(function(hit) -- good
if hit.Parent:FindFirstChild("Humanoid") then -- good also if this is only for players it will work for ai to if their humanoid is named humanoid
--[[for i = 1,100 do
if script.Parent.Frame.BackgroundTransparency == 0 then
break
end
script.Parent.Frame.BackgroundTransparency -= 0.05
wait(0.0001)
end
wait(2)
for i = 1,100 do
if script.Parent.Frame.BackgroundTransparency == 1 then
break
end
script.Parent.Frame.BackgroundTransparency += 0.05
wait(0.0001)
end]]
tweenserv:Create(script.Parent.Frame, TweenInfo.new(1--[[TIME]], Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0--[[repeat count]], true--[[whether or not the tween reverses]]), {BackgroundTransparency = 1}--[[properties to change]]):Play()
hit.Parent:PivotTo(game.Workspace.pivot2.CFrame)
wait(1)
tpRedDoor.BrickColor = BrickColor.new("Cocoa")
end
end)
end)
end)
And as you see i gave the for loop ver in square brackets too. So how can i make the fading gui here? Thanks to anyone can help!