Currently, I’m try to get this type of effect originally seen in Baldi’s Basics Plus.
As you can see, the 1 balloon just bounces off of the wall and tweens to a random position in a random direction for a random amount of time. Really random.
Right now, this is how it is in game (I have AlwaysOnTop checked on).
As you can see again, the 9 balloon just kinda phases through the walls. I’ve tried looking at some older DevForum posts (like this) and I’m kind of confused. Also I’m using the “outdated” version of the script that was used in the DevForum thread because it’s the only one that worked for some odd reason. If the newer one works that was posted by the same guy a year later, I’ll use it i guess
This is my current script for the part to float around and to stay in bounds of the BalloonBase part, which just covers the whole room that it’s supposed to stay in.
local base = script.Parent.Parent.BalloonBase
local part = script.Parent
local startPos = part.Position
local respawn = Vector3.new(-69, 10, 369)
while true do
local BaseSizeX = math.random(1,30)
local BaseSizeZ = math.random(1,10)
local waitTime = math.random(4,6)
TweenService:Create(part, TweenInfo.new(waitTime,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0), {
Position = startPos + Vector3.new(BaseSizeX, 0, BaseSizeZ)
}):Play()
local Vectors = {Vector3.new(0,0,1), Vector3.new(0,0,-1), Vector3.new(1,0,0), Vector3.new(-1,0,0), Vector3.new(0,1,0), Vector3.new(0,-1,0)}
local function CheckIfPart()
for _, Vector in pairs(Vectors) do
local BaseEnd = base.Position + (base.Size * Vector)/2 --Finds the edge of the base part
local ControlEnd = part.Position + (part.Size * Vector)/2 --Finds the edge of the control part
local BaseDirection = (base.Position - BaseEnd).Unit
local ControlDirection = (BaseEnd - ControlEnd).Unit * BaseDirection
--What we'll end up doing is checking the unit direction of the base part and the control part, compared it to the BaseDirection
--What ends up happening is if the direction is negative, it's in bounds. if it's positive, it's out of bounds
if ControlDirection.X > 0 or ControlDirection.Y > 0 or ControlDirection.Z > 0 then
return false
end
end
local partsound = Instance.new("Part")
partsound.Transparency = 1
partsound.CanCollide = false
partsound.Anchored = true
partsound.Name = "POP"
partsound.Position = part.Position
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://117051487554708"
sound.RollOffMinDistance = 1
sound.RollOffMaxDistance = 50
sound.Volume = 10
sound:Play()
part.Position = respawn
return true
end
print(CheckIfPart()) **-- In the GIF of how it currently looks in game, you can see how it always prints out false, which false is SUPPOSED to mean that it's in the BalloonBase, even though it's not. Why? I dunno!**
task.wait(waitTime)
end
Basically I just want a tweened part to check its position constantly to make sure it doesn’t go out of the room/BalloonBase part and it bounces off of other parts if necessary, like the walls. Help is appreciated!