Placing a Range Limitation on Summoned Objects

I'm using the ability script from the Zero to Valorian tutorial to power an ability to summon temporary barriers. However, I can't figure out a way to modify the script to put a distance constraint on the range an object can be summoned into the world. Any suggestions?

Where could one find this "Zero to Valorian tutorial"?

From what I understand about this script (I am mostly guessing here because I cannot find this tutorial anywhere), it is using a raycast to determine where the object will be placed, you could limit the distance players can place objects by decreasing the length of the raycast.

Oops, the name was Zero to Valorant.

I'll see if I can figure out how to limit the length of the raycast though.

Thanks for replying man.

You will need to modify the code they give you to use raycasts instead of AbilityTarget. The code below would allow you to spawn an ice wall whenever the "IceWallAbility" is cast. Look through the comments to determine which custom properties you need to add.

--Asset Reference to the Ice Wall
local propIceWall = script:GetCustomProperty("IceWall")

--Core Object Reference to the ability that spawn the ice wall
local Ability = script:GetCustomProperty("IceWallAbility"):WaitForObject()
--Function called whenever the ability is cast
function OnCast(ability)
    --Length of the ray that will check for players to spawn ice walls
   local RayLength = 3000
  --GGet the look direction of the player
   local lookDirection = Quaternion.New(ability.owner:GetLookWorldRotation()):GetForwardVector()
  --Set the starting position to the player's head
   local RayStart = Ability:GetWorldPosition() + (Vector3.UP*150)
   --Set the ending position of the raycast 
   local RayEnd = RayStart + (lookDirection*RayLength)
  --Get the hitresult of the ray cast
    local hit = World.Raycast(RayStart, RayEnd)
    --Check if a player was hit
    if(hit ~= nil and hit.other ~= nil) then
         local hitPos = hit:GetImpactPosition()
         World.SpawnAsset(propIceWall, {position=hitPos})
    end
end

--Bind the "OnCast" function to the "castEvent" of the "Ability" object
Ability.castEvent:Connect(OnCast)

Awesome, thank you sir.