So I wanted to make a part to run like change the player speed when touched.
But R15 keep touched and ended so I have no idea what should I do to fix this (R15).
3 Likes
you can detect when touched ended if player’s distance from part is larger than X, if yes then remove effect, else stay as it is
1 Like
apparently the part is long but not for the side it thin so If I detect it how would I detect it?
2 Likes
You can try :GetPartBoundsInBox, example
local partsIn = game.Workspace:GetPartsBoundInBox(centerCFrame, sizeVector3, OverlapParams)
Documentation:
1 Like
My solution is using raycast to find part that in range of 10 stud
local player = game.Players.LocalPlayer
local char = player.CharacterAdded:Wait()
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Include
local direction = Vector3.new(0, -10, 0) -- Ray floor
while task.wait() do
params.FilterDescendantsInstances = {workspace.A, workspace.B} -- I made this because sometimes If it far away the part isn't load or smt but it doesn't work like If Im stand near part A and far from part B it doesn't part B load.
local rayResult = workspace:Raycast(char.HumanoidRootPart.Position, direction, params) -- Ray from hrp to down direction
if rayResult and rayResult.Instance then
if rayResult.Instance.Name == "A" or rayResult.Instance.Name == "B" then
-- do function here
end
else
-- does any function
end
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.