Hello, I’m trying to make this script work for each part as shown in the video, however only one seems to trigger and then after the tween is finished i am able to trigger another, I want to trigger as many as I can but not trigger the same that already was tweening ( not fun results ), how could I go around this?
Video:
https://i.gyazo.com/8ee49603af0250f45c0d4f76b32f4bd6.mp4
Script:
local Players = game:GetService("Players")
local debounce = false
local function onCharacterAdded(char)
local hum = char:WaitForChild("Humanoid")
local torso = char:WaitForChild("Torso")
local wtb = char:WaitForChild("WantsToBuild")
local legL = char:WaitForChild('Left Leg')
local legR = char:WaitForChild('Right Leg')
if hum then
hum.Changed:Connect(function()
if hum.FloorMaterial == Enum.Material.Sand and wtb.Value == true then
local myray = Ray.new(torso.Position, Vector3.new(0,-10,0))
local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(myray, {hum, legR, legL})
if hit.Name == 'Snow' then
if debounce then return end
debounce = true
print(hit.Name..' was hit')
local tween = game:GetService('TweenService')
local info = TweenInfo.new(
5, --seconds it takes to complete loop
Enum.EasingStyle.Linear, --easingstyle (how it moves)
Enum.EasingDirection.InOut, --easingdirection (which direction)
0, --times repeated (negative number if u want infinite)
true, --reverse (does it go back to its spot)
0 --delay time (stoptime before doing the tween)
)
local Goals = { --YOU CAN CHANGE THESE AND DELETE THE THINGS YOU DON'T WANT TO TWEEN
Transparency = 1,
Position = Vector3.new(hit.Position.X, hit.Position.Y -2.5, hit.Position.Z)
}
local start = tween:Create(hit, info, Goals) --gets all the info and goals and creates tween
start:Play()
start.Completed:Wait()
print('done')
debounce = false
else
-- print('air')
end
end
end)
end
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)