Hello, as you can see on the video, the meteor goes on without pause. I would like to know if there is a way to put a waiting time between two appearances? Thanks. (I have tried different scripts without success)
--Script in a local Script in StarterCharacterScripts
local ts = game:GetService("TweenService")
local p1 = game.Workspace.Meteorite.avion2
local p2 = game.Workspace.Meteorite.avion1
local ball = game.Workspace.Meteorite.meteor
local function moveItem(item, wp)
local ti = TweenInfo.new(3, Enum.EasingStyle.Linear,
Enum.EasingDirection.Out, (1/0), false, 0)
local tween = ts:Create(item, ti,
{ Position = wp.Position })
wait(10)
tween:Play()
end
wait(10)
moveItem(ball, p1)
moveItem(ball, p2)
moveItem(ball, p1)
local function onTouch(hit)
if hit.Parent.Name == ball then
wait(10)
end
end
game.Workspace.Bases.Touched(onTouch)
Or maybe make it invisible for a while (maybe when it touches the area below) and bring it back later (even if I’m not a fan of this option because not ideal for unnecessary lag)
local function onTouch(hit)
if hit.Parent.Name == ball then
wait(10)
end
end
game.Workspace.Bases.Touched(onTouch)
What exactly is this doing? It fires the function every time the bases are hit, checks to see if it’s a ball then waits. Every time anything hits the Bases the function gets called. If it’s a ball then the function waits 10 seconds but if something touches the Bases again in that 10 seconds, the function gets called again.
Put a print statement in that function to see what I mean.
If you have more stuff to do in that function that you didn’t include that’s fine, but then you need a Debounce – When and Why to keep it from firing repeatedly.
local Debounce = false
local function onTouch(hit)
if hit.Parent.Name == ball.Name then
if Debounce then return end
Debounce = true
wait(10)
Debounce = false
end
end
workspace.Bases.Touched:Connect(onTouch)
I do not understand why the output does not react when it touches the base, I have the impression that the tweenservice prevents the collision in the output
Unfortunately it doesn’t work, the output doesn’t react either. I don’t know how to make it disappear once it touches the ground. The other solution is not bad but it’s a pity that the meteor stays on the ground. Thank you for your help
The reason the .Touched event is not firing is because of the tween. When tweening, you are smoothly changing a property of an instance. This means that if you are just changing positions, rotations or cframe, it wont fire any physics related event (unless the part is unanchored in this case it will be visually buggy).