I’m trying to make region3 zones that play a start sound and a looping sound for a grinding a skateboard.
The region3s are made with part position and stuff that are in a folder in workspace, ‘Rails’ and ‘Ledges’ and it is working perfectly with one part in the folders but as soon as theres more then that it starts looping sounds and it just generally breaks.
I’ve tried with help from a friend to think of ways to fix, I thought to make a table for the parts/region3s but im not too sure how to do that.
This is what happens when you go on a rail when theres 2 parts in the folder, doesnt matter what part you jump on the same thing happens. You can see it in the video.
while wait(.1) do
for i, v in pairs(rails:GetChildren()) do
OnRail = false
local region = Region3.new(v.Position - (v.Size/2),v.Position + (v.Size/2))
local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region,game.Players.LocalPlayer.Character:GetDescendants())
for _, part in pairs(parts) do
if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
OnRail = true
break
else
OnRail = false
break
end
end
if OnRail == true then
if FakeRailLoop.IsPlaying == false then
Remotes.Sound:FireServer("startrail")
FakeRailLoop:Play()
FakeRailStart:Play()
break
end
else
FakeRailLoop:Stop()
Remotes.Sound:FireServer("stoprail")
end
for i, v in pairs(ledges:GetChildren()) do
OnLedge = false
local region2 = Region3.new(v.Position - (v.Size/2),v.Position + (v.Size/2))
local parts2 = game.Workspace:FindPartsInRegion3WithWhiteList(region2, game.Players.LocalPlayer.Character:GetDescendants())
for _, part in pairs(parts2) do
if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
OnLedge = true
break
else
OnLedge = false
break
end
end
if OnLedge == true then
if FakeLedgeLoop.IsPlaying == false then
Remotes.Sound:FireServer("startledge")
FakeLedgeLoop:Play()
FakeLedgeStart:Play()
break
end
else
FakeLedgeLoop:Stop()
Remotes.Sound:FireServer("stopledge")
end
end
end
end