I’m trying to create reflections but I’ve encountered a problem. When I put the character in-front of it to test, it clones the character WAYY to many times and almost crashes my ROBLOX studio. And no, this is 100% not because of a virus. Here’s what I’ve tried:
NOT THE FULL CODE
function lighting.reflect(partthatreflects, partthatemmits, parttoreflectonto)
local hasbeenhit = false
local ray = script.Ray:Clone()
local tweenservice = game:GetService("TweenService")
local info = TweenInfo.new(3, Enum.EasingStyle.Linear,Enum.EasingDirection.Out, 100000000000, true, 0)
local goal = {
Size = Vector3.new(partthatreflects.Size.X, partthatreflects.Size.Y, 2048)
}
ray.Position = partthatemmits.Position
ray.Parent = workspace
local created = tweenservice:Create(ray, info, goal)
created:Play()
ray.Touched:Connect(function(hit)
local debounce = false
hasbeenhit = true
local clone = hit:Clone()
debounce = true
wait(10)
debounce = false
if hasbeenhit == true then
local debounce = false
clone.Position = parttoreflectonto.Position
clone.Parent = workspace
debounce = true
wait(1)
debounce = false
end
end)
end
What it does:
https://gyazo.com/e211189cceec3392905af4fa9df6b714
Yes, I know the part’s can collide is true.