I need help help with hitbox trail

i have a script that makes a trail when you walk or jump, is it possible to create 60 blocks per second instead of 30?

image

script

local plr = game:GetService("Players").LocalPlayer
local userinput = game:GetService("UserInputService")
local rp = game:GetService("ReplicatedStorage")

local movedval = script:WaitForChild("moved")

while not plr.Character do
	wait()
end

local char = plr.Character
local nameadder = 1

local hum = char:WaitForChild("Humanoid")

userinput.InputBegan:Connect(function(inp, ga)
	if inp.KeyCode == Enum.KeyCode.W then
		movedval:FindFirstChild("W").Value = true
	elseif inp.KeyCode == Enum.KeyCode.A then
		movedval:FindFirstChild("A").Value = true
	elseif inp.KeyCode == Enum.KeyCode.S then
		movedval:FindFirstChild("S").Value = true
	elseif inp.KeyCode == Enum.KeyCode.D then
		movedval:FindFirstChild("D").Value = true
	elseif inp.KeyCode == Enum.KeyCode.Space then
		movedval:FindFirstChild("Space").Value = true
	end
end)

userinput.InputEnded:Connect(function(inp, ga)
	if inp.KeyCode == Enum.KeyCode.W then
		movedval:FindFirstChild("W").Value = false
	elseif inp.KeyCode == Enum.KeyCode.A then
		movedval:FindFirstChild("A").Value = false
	elseif inp.KeyCode == Enum.KeyCode.S then
		movedval:FindFirstChild("S").Value = false
	elseif inp.KeyCode == Enum.KeyCode.D then
		movedval:FindFirstChild("D").Value = false
	elseif inp.KeyCode == Enum.KeyCode.Space then
		movedval:FindFirstChild("Space").Value = false
	end
end)

for _, v in ipairs(movedval:GetChildren()) do
	v:GetPropertyChangedSignal("Value"):Connect(function()
		if movedval.W.Value == true or movedval.A.Value == true or movedval.S.Value == true or movedval.D.Value == true or movedval.Space.Value == true then
			movedval.Value = true
		else
			movedval.Value = false
		end
	end)
end

local fold = game.Workspace:WaitForChild("cp's")

while true do
	wait(1 / rp:WaitForChild("cps").Value)
	if movedval.Value == true and rp:WaitForChild("trailon").Value == true then
		local trail = Instance.new("Part",  fold)
		
		trail.Name = tostring(nameadder)
		trail.CFrame = char:FindFirstChild("Torso").CFrame
		trail.Transparency = 0.75
		trail.Size = Vector3.new(2, 2, 1)
		trail.Color = Color3.new(1,0,0)
		trail.Anchored = true
		trail.CanCollide = false
		trail.Material = Enum.Material.SmoothPlastic
		
		nameadder = nameadder + 1
	end	
end

image

Use task.wait instead of wait. Wait throttles and task.wait can go as low as 1/60th of a second.

Thank you it worked, i changed wait to task.wait and now trail is more accurate

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