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 want it to wait 5 seconds while player is sitting in a seat and the overhead gui to do some epik tweening after that give da player a tool -
What is the issue? Include screenshots / videos if possible!
The script just freezes without any errors after the 5 seconds has passed -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I haven’t found any solutions online :c
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!
local seat = script.Parent
local Tween = game:GetService("TweenService")
local ss = game:GetService("ServerStorage")
local toolFolder = ss:WaitForChild("Tools", 5)
local tool = toolFolder:WaitForChild(seat.Name, 5)
local frame2:Frame = script.Parent:WaitForChild("Gui"):WaitForChild("Frame1"):WaitForChild("Frame2")
local frame1:Frame = script.Parent:WaitForChild("Gui"):WaitForChild("Frame1")
local yes = 5
local waitTime = 5
local function lol(plr:Player)
if not plr:FindFirstChild(tool.Name) then
tool:Clone().Parent = plr:WaitForChild("Backpack")
task.wait(.1)
plr.Character:WaitForChild("Humanoid").Jump = true
else
task.wait(.1)
plr.Character:WaitForChild("Humanoid").Jump = true
end
end
-- Function to track sitting duration
local function yay()
local occupant = seat.Occupant
if occupant then
local humanoid = occupant.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
local plr = game.Players:GetPlayerFromCharacter(humanoid.Parent)
if plr then
yes = 5
frame1.UIStroke.Enabled = true
frame2.BackgroundTransparency = 0
task.spawn(function()
while yes > 0 do
task.wait(.1)
if seat.Occupant == humanoid then
yes = yes - .1
local size = math.clamp(yes / waitTime, 0 ,1)
anim = Tween:Create(frame2, TweenInfo.new(.1) ,{Size = UDim2.new(size, 0, 1, 0)})
-- i aint changing this variable above to a local for a reason
anim:Play()
if yes == 0 then
lol(plr)
anim:Cancel()
frame1.UIStroke.Enabled = false
frame2.BackgroundTransparency = 1
frame2.Size = UDim2.new(1, 0, 1, 0)
break
end
else
anim:Cancel()
frame1.UIStroke.Enabled = false
frame2.BackgroundTransparency = 1
frame2.Size = UDim2.new(1, 0, 1, 0)
break
end
end
end)
end
end
end
end
-- Connect to the Occupant property change
seat:GetPropertyChangedSignal("Occupant"):Connect(yay)
-- In case a player is already sitting when the script starts
if seat.Occupant then
yay()
end
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.