Newspaper wind simulation

I am currently working on a newspaper part simulating a breeze is there any improvements you have if so answer these questions:
What do you like about it?
How or what can I improve on this?
Here’s a video of the simulation scroll down to see the script


The script:


local part = script.Parent ----- The script is a child of the part
part.Anchored = true -------- Has to be anchored or it will go to the center of the workspace
local Direction = {"-","+"}-------- If the Corernate goes in a certain direction ex: Left, Right but uses negative or positive
local Interval = 2 ------- Time it waits to move again don't put this to 0 tho
local MaxMoveIncerment = -1  ----- Max the part can move remeber -1 is larger than -5
local MinMoveIncerment = -5  ----- Minimal that the part can move
local RotateIncerment = 1 ---- Rotate by please be aware that the object rotates randomly
function Propbability(Number)----------- Dicides the parts direction
	local random = Direction[math.random(1, table.maxn(Direction))]
	if random == "-" then
		return math.abs(Number)
	elseif random == "+" then
		return math.abs(Number)*-1
	end
end

while true do -------- Simulates the breeze
	wait(Interval)
	local X = math.random(MinMoveIncerment, MaxMoveIncerment)
	game.TweenService:Create(part, TweenInfo.new(Interval), {CFrame = part.CFrame*CFrame.new(X,0,0)*CFrame.fromEulerAnglesXYZ(0,Propbability(RotateIncerment),0)}):Play()
end

----_______ PLEASE NOTE THAT THIS IS A SIMPLE ONE THIS DOESN'T HAVE COLLISION DEDECTION SO IT WILL NOCLIP THROUGH EVERYTHING FEEL FREE TO EDIT THIS ONE


Thank you if you feedbacked

1 Like

Everything, it’s amazing.

Perhaps collision detection (You can do this by creating an invisible newspaper and checking if it’s checking anything)
And maybe you could make the newspaper go up in the air for a second, as it’s moving

Edit: Here’s the collision script if you want/need it

local part = script.Parent ----- The script is a child of the part
part.Anchored = true -------- Has to be anchored or it will go to the center of the workspace
local Direction = {"-","+"}-------- If the Corernate goes in a certain direction ex: Left, Right but uses negative or positive
local Interval = 2 ------- Time it waits to move again don't put this to 0 tho
local MaxMoveIncerment = -1  ----- Max the part can move remeber -1 is larger than -5
local MinMoveIncerment = -5  ----- Minimal that the part can move
local RotateIncerment = 1 ---- Rotate by please be aware that the object rotates randomly
function Propbability(Number)----------- Dicides the parts direction
	local random = Direction[math.random(1, table.maxn(Direction))]
	if random == "-" then
		return math.abs(Number)
	elseif random == "+" then
		return math.abs(Number)*-1
	end
end

while true do -------- Simulates the breeze
	wait(Interval)
	local CanMove = true
	local X = math.random(MinMoveIncerment, MaxMoveIncerment)
	local ColisionDetect = Instance.new("Part")
	ColisionDetect.Parent = workspace
	ColisionDetect.Size = part.Size
	ColisionDetect.CFrame = part.CFrame*CFrame.new(X,0,0)*CFrame.fromEulerAnglesXYZ(0,Propbability(RotateIncerment),0)
	ColisionDetect.Anchored = true
	local  Check = ColisionDetect:GetTouchingParts()
	for i, x in pairs(Check) do
		if x.CanCollide == true and x ~= part then
			CanMove = false
		end
	end
	ColisionDetect:Destroy()
	if CanMove == true then
		game.TweenService:Create(part, TweenInfo.new(Interval), {CFrame = part.CFrame*CFrame.new(X,0,0)*CFrame.fromEulerAnglesXYZ(0,Propbability(RotateIncerment),0)}):Play()
	end
end

Oh wow, I did not know this I swear I need to get good at physics thanks! I thought I had to detect the parts using complex stud distance but this will do. :+1:

1 Like