Hello I’m trying to make a rock effect but the problem is every time it’s the edge a part still spawns and will break the script. I tried to look in the dev forum but can’t find anything. Help would be great
What I got:
What I wanted:
local rock = Instance.new("Part")
rock.Anchored = true
rock.CanCollide = false
rock.Size = Vector3.new(SizeZ,SizeZ,SizeZ)
rock.CFrame = obj.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(Ori),0) * CFrame.new(Room,2,-Room)
rock.Orientation = Vector3.new(math.random(-20,20),math.random(-20,20),math.random(-20,20))
rock.Parent = workspace.FXDebris
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Blacklist
rayParams.IgnoreWater = true
local result = workspace:Raycast(rock.Position,Vector3.new(0,-h,0),rayParams)
if result then
rock.Position = (result.Position - Vector3.new(0,SizeZ,0))
rock.Color = result.Instance.Color
rock.Material = result.Material
TweenService:Create(rock,TweenInfo.new(1), {Position = result.Position}):Play() delay(T,function()
TweenService:Create(rock,TweenInfo.new(1), {Position = result.Position - Vector3.new(0,SizeZ,0)}):Play()
end)
end