How to make balls(Photons) with align position reflect from walls?

  1. What do you want to achieve? Keep it simple and clear!
    Topic says everything
  2. What is the issue? Include screenshots / videos if possible!
    I done this with simple touch function, buut this happens
    image
    they just get stuck because of random trajectory after hit(code later)
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I was thinking about making reflectance in other side like this

    like it was falling 45* to surface and reflected 45* to surface. But idk how to do it

My current code:


function create()
	local random = Random.new()
	local randomTrajX = random:NextNumber(1000, -1000)
	local randomTrajZ = random:NextNumber(1000, -1000)
	local randomTrajY = random:NextNumber(1000, -1000)
	script.Parent.AlignPosition.Position = Vector3.new(randomTrajX, randomTrajY, randomTrajZ)
end

create()
script.Parent.Touched:Connect(function()
	create()
end)

with this code stuck thing is happening

Well i tryed asking ChatGPT, his solutions are kinda hard and performance-bad. I wanna photons just reflect in mirrored direction like light Ray falling on straight glass(45* falling → 45* reflecting(example)) and also not stuck on floor

shouldn’t you try doing this with raycast
you could get the position it would need to go based on raycast instead of using u could probably use magnitude to see if the position is close enough to reflect then theres another raycast based on reflection but making it advanced as in detecting if something moved in its way would probably be costing