having multiple problems with my bowling lane which is getting really frustrating to figure out which i could use some help on,
the bowling lane just doesn’t seem to pick up all the pins when i want it to, and the physics seem to be really weird when the animation for the pinsetter places the pins down so that the player can roll again. it seems that it just collides through the floor and then goes back up, but even if i got it right, the pins seem to just randomly tilt to an angle and slowly fall on their side. on the other hand, the sweeper that should clean out all the pins don’t even clearly do what it needs to do as the sweeper just straight up goes through the pins like the pins never existed.
i’m aware that the animation collisions are quite whack, and i have researched around and about for that subject however i am not bothering with making my own physics system as i think that’s just seriously too much for this kind of thing i want. for the pins just slowly tilting until their demise to their side, i tried to lock them in parts as shown below, but it didn’t make any difference.
as for the pins that just don’t get picked up, i’m not sure what’s causing that. the code below is basically the entire system for how i do the bowling lane. i thought i had done the math logic right since i’m checking for both, WHETHER the bowling pin has fallen to its side, and that the bowling pin is still around in the spot that it should be.
local tweenService = game:GetService("TweenService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local bowlingLane = script.Parent
local bowlingpins = bowlingLane["bowling pins"]
local scanner = bowlingLane.Scanner
local sweeper = bowlingLane.sweeper
local scooper = bowlingLane.scooper -- thing that picks up ur pins
local sweeperKeyFrames = sweeper.Keyframes
local alreadycleaning = false
local turn = 1
local totalCount = 0
--211.601, -0.775, 7.593
local function countPinsKnocked()
-- passed first test, are the pins standing?
local passedFirstTest = {}
local count = 0
local pinsStillStanding = workspace:FindPartsInRegion3(Region3.new( Vector3.new(
scooper.check.Position.x - scooper.check.Size.x/2,
scooper.check.Position.y - scooper.check.Size.y/2,
scooper.check.Position.z - scooper.check.Size.z/2
),
Vector3.new(
scooper.check.Position.x + scooper.check.Size.x/2,
scooper.check.Position.y + scooper.check.Size.y/2,
scooper.check.Position.z + scooper.check.Size.z/2) ) )
-- how many pins still stand
for _, pin in pairs(pinsStillStanding) do
-- prevent error from index number with 'typeof'
if typeof(pin) ~= "number" then
if pin:IsA("MeshPart") and string.sub(pin.Name, 1, 3) == "pin" then
table.insert(passedFirstTest, pin)
end
end
end
-- since we know that it didnt pass that sinngle check, we can now see if any pins are standing in their correct desired position.
for i, pin in pairs(passedFirstTest) do
if pin:FindFirstChild("stand") then
local stand = workspace:FindPartsInRegion3(Region3.new( Vector3.new(
pin:FindFirstChild("stand").Position.x - pin:FindFirstChild("stand").Size.x/2,
pin:FindFirstChild("stand").Position.y - pin:FindFirstChild("stand").Size.y/2,
pin:FindFirstChild("stand").Position.z - pin:FindFirstChild("stand").Size.z/2
),
Vector3.new(
pin:FindFirstChild("stand").Position.x + pin:FindFirstChild("stand").Size.x/2,
pin:FindFirstChild("stand").Position.y + pin:FindFirstChild("stand").Size.y/2,
pin:FindFirstChild("stand").Position.z + pin:FindFirstChild("stand").Size.z/2) ) )
for _, pin in ipairs(stand) do
-- prevent error from index number with 'typeof'
if typeof(pin) ~= "number" then
if pin:IsA("MeshPart") and string.sub(pin.Name, 1, 3) == "pin" and string.sub(pin.Name, 5, 6) == i then
-- the pin is still standing
table.remove(passedFirstTest, table.find(passedFirstTest, pin))
count += 1
end
end
end
end
end
count = 10 - #passedFirstTest
totalCount = count
return passedFirstTest
end
for _, v in bowlingLane.ANCHORS:GetChildren() do
for _, w in v:GetChildren() do
w.CanCollide = false
w.Transparency = 1
end
end
scanner.Touched:Connect(function(hit)
if hit.Name == "BowlingBall" and not alreadycleaning then
bowlingpins = bowlingLane["bowling pins"]
local clone = nil
local amountKnocked = nil
alreadycleaning = true
wait(0.5)
tweenService:Create(sweeper.PrimaryPart, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {CFrame = CFrame.new(sweeperKeyFrames.Frame1.Position) }):Play()
wait(2)
-- start cleaning and counting
if turn == 2 or totalCount == 10 then
tweenService:Create(scooper.PrimaryPart, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, true), {CFrame = CFrame.new(scooper.Keyframes.Frame2.Position)}):Play()
wait(0.5)
clone = game:GetService("ReplicatedStorage")["bowling pins"]:Clone()
clone.Parent = bowlingLane
for _, v in clone:GetChildren() do
v.Anchored = true
v.Position = Vector3.new(v.Position.X, 3.3, v.Position.Z)
tweenService:Create(v, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = Vector3.new(v.Position.X, 2, v.Position.Z)}):Play()
end
else
tweenService:Create(scooper.PrimaryPart, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true), {CFrame = CFrame.new(scooper.Keyframes.Frame1.Position)}):Play()
wait(1)
amountKnocked = countPinsKnocked()
for i, v in amountKnocked do
v.Anchored = true
tweenService:Create(v, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {Position = Vector3.new(v.Position.X, 2, v.Position.Z)}):Play()
end
wait(1)
end
tweenService:Create(sweeper.PrimaryPart, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {CFrame = CFrame.new(sweeperKeyFrames.Frame2.Position) }):Play()
wait(1)
tweenService:Create(sweeper.PrimaryPart, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {CFrame = CFrame.new(sweeperKeyFrames.Frame1.Position) }):Play()
wait(1)
for _, v in bowlingLane.ANCHORS:GetChildren() do
for _, w in v:GetChildren() do
w.CanCollide = true
end
end
tweenService:Create(scooper.PrimaryPart, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true), {CFrame = CFrame.new(scooper.Keyframes.Frame1.Position)}):Play()
if turn == 2 or totalCount == 10 then
bowlingpins:Destroy()
if clone then
for _, v in clone:GetChildren() do
local tween = tweenService:Create(v, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = Vector3.new(v.Position.X, -1.697, v.Position.Z)})
tween:Play()
tween.Completed:Connect(function()
wait(0.5)
v.Anchored = false
end)
end
end
totalCount = 0
turn = 1
else
for i, v in amountKnocked do
local tween = tweenService:Create(v, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = Vector3.new(v.Position.X, -1.697, v.Position.Z)})
tween:Play()
tween.Completed:Connect(function()
wait(0.5)
v.Anchored = false
end)
end
turn = 2
end
wait(1)
tweenService:Create(sweeper.PrimaryPart, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {CFrame = CFrame.new(sweeperKeyFrames.Frame3.Position) }):Play()
alreadycleaning = false
spawn(function()
wait(1)
for _, v in bowlingLane.ANCHORS:GetChildren() do
for _, w in v:GetChildren() do
w.CanCollide = false
end
end
end)
end
end)
sweeper.Union:GetPivot()
if anyone can, could anyone please help me on this? i’m really starting to give up on this and the amount of headaches i’ve got trying to fix this is immense.