Sprint Script | Raycast Params Help

Hello,

Recently I have been working on including sprinting into my game and I came upon a helpful debris sprint script, but have encountered a little issue with params.

For example →

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Whitelist
params.FilterDescendantsInstances = {workspace}

This is the code I am using for the local part of it. Although, it normally works when I use params.FilterDescendantsInstances = {workspace.ACERTAINFOLDER}.

Now that I am using a HUGE map, and can’t put every part/thing into one folder, i’m curious why params.FilterDescendantsInstances={workspace} doesn’t just grab all the parts in it?

I tried GetDescentants() as well, but that seem to not work.

How can I go about this?

For example here is the line of code that does the RayCast →

local rayResult = workspace:Raycast(step.Position + Vector3.new(0,1,0), Vector3.new(0,-3,0), params)

NOTE :

BASICALLY THIS SPRINT SCRIPT NORMALLY LEAVES DEBRIS IF I USE WORKSPACE.FOLDER BUT I JUST WANT IT TO BE CHECKING EVERY PART IN WORKSPACE.

Just leave out the raycast params. If you want everything in workspace to be registered, there’s no need for a whitelist or a blacklist.

1 Like

^ Yeah, because all visible (and ray-collidable) parts are on the Workspace anyway

Wait…

You don’t use folders?

I have plenty of folders, that’s what I meant above.

I’ll take a look at this!

What should be replaced instead of Params?

local rayResult = workspace:Raycast(step.Position + Vector3.new(0,1,0), Vector3.new(0,-3,0), params)

Just leave it blank, the params parameter isn’t required.

local rayResult = workspace:Raycast(step.Position + Vector3.new(0,1,0), Vector3.new(0,-3,0))
1 Like

Okay, well I did try leaving it blank, and their still seems to be no debris/effects being added?

I want there to be debris for all parts… That are being stepped on.

local rayResult = workspace:Raycast(step.Position + Vector3.new(0,1,0), Vector3.new(0,-3,0))
			if rayResult then
				step.Attachment.Dust.Color = ColorSequence.new{
					ColorSequenceKeypoint.new(0, rayResult.Instance.Color),
					ColorSequenceKeypoint.new(1, rayResult.Instance.Color)
				}
			end
			step.Attachment.Dust:Emit(10)
			game.Debris:AddItem(step,1)
			direction = direction * -1

That’s quite weird. Try adding a blacklist raycastParameter with the blacklist of the player’s character.

Seem to not be working…

Quite weird supposing, It was working with →

params.FilterDescendantsInstances = {workspace.FOLDER}

Hm.

I wonder how I can do this.

What do you define step as in the script? Also, are there any errors?

Here’s most of the script.

local player = game.Players.LocalPlayer
local character = script.Parent
local humanoid = character.Humanoid
local lastrun = 0
local direction = 1
local lastPosition = character.PrimaryPart.Position
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Whitelist
params.FilterDescendantsInstances = {workspace}


RS.Heartbeat:Connect(function()
	if (character.PrimaryPart.Velocity * Vector3.new(1,0,1)).Magnitude > WALKSPEED * 2 and humanoid.FloorMaterial ~= Enum.Material.Air then
		if tick() - lastrun > 6/RUNSPEED then
			lastrun = tick()
			
			local step = fx.Dust:Clone()
			step.Parent = workspace.Fx
			step.CFrame = character.PrimaryPart.CFrame * CFrame.new(direction, -3,0)
			local rayResult = workspace:Raycast(step.Position + Vector3.new(0,1,0), Vector3.new(0,-3,0), params)
			if rayResult then
				step.Attachment.Dust.Color = ColorSequence.new{
					ColorSequenceKeypoint.new(0, rayResult.Instance.Color),
					ColorSequenceKeypoint.new(1, rayResult.Instance.Color)
				}
			end
			step.Attachment.Dust:Emit(10)
			game.Debris:AddItem(step,1)
			direction = direction * -1
		end
		
		for i = 1, math.random(1,3) do
			local hb = Instance.new("Part", workspace.Fx)
			hb.Anchored = true
			hb.CanCollide = false
			hb.Transparency = 0.8
			hb.Name = "hb"
			hb.Material = Enum.Material.SmoothPlastic
			hb.CanQuery = false
			hb.Size = Vector3.new(0.07,0.07, math.random(4,6))
			local colorRand = math.random(1,3)
			if colorRand == 1 then
				hb.Color = Color3.fromRGB(0,0,0)
			else
				hb.Color = Color3.fromRGB(180,180,180)
			end
			
			local dirCFrame = CFrame.new(lastPosition,character.PrimaryPart.Position)
			hb.CFrame = dirCFrame * CFrame.new(math.random(-25,25)/10,math.random(-3,3),math.random(-2,2))
			game.Debris:AddItem(hb,0.2)
			TS:Create(hb,TweenInfo.new(0.2),{Transparency = 1, Size = Vector3.new(0,0,0), CFrame = hb.CFrame * CFrame.new(0,0, math.random(2,4))}):Play()
			
		end
	else
		direction = 1
	end
	lastPosition = character.PrimaryPart.Position
end)

Step = a little part in workspace folder, it’s like the Effects.

Try changing the params to this:

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = {character}

This was the issue now I realize (not showing in general) →

if (character.PrimaryPart.Velocity * Vector3.new(1,0,1)).Magnitude > WALKSPEED * 2 and humanoid.FloorMaterial ~= Enum.Material.Air then

Because I want to do →

local WALKSPEED = 16
local RUNSPEED = 25

But that doesn’t work if it’s 25…

Leaving it blank worked! I’ll have to figure out how to check that, but make sure it’s not that fast. Thank you :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.