#Can't detect touch

1 messages · Page 1 of 1 (latest)

sacred tusk
#

Hello, i'm trying to make a heat seeking part by updating its cframe every frame with runservice.Heartbeat, im trying to check if it collides with another part, but it's not detecting it with .Touched, its detecting baseplate and the player, but not the normal part I made

random blaze
#

what script are you using

drifting hatchBOT
#

studio** You are now Level 6! **studio

random blaze
#

you're probably using normal script cuz u use heartbeat

#

but if you are using local then remove heartbeat and replace it with renderstepped

#

also try to use datastore

#

if touched isn t working

random blaze
#

wut

#

im just an idiot

#

who tries to help people

simple jacinth
#

wdym

#

you not an idiot

random blaze
#

oh im not?

simple jacinth
#

you just trying to help brah

random blaze
#

yay

#

OH WAIT UR LVL 3 crying

sacred tusk
random blaze
#

also pls share script

sacred tusk
random blaze
#

cuz datastore only stores data

#

ur part needs to be 3D

sacred tusk
#

im trying to send the code as a code thing hold on

drifting hatchBOT
#

studio** You are now Level 5! **studio

sacred tusk
simple jacinth
#

okay bro chill

#

just send it

random blaze
sacred tusk
#

OKAY IM SENDING IT SORRY

simple jacinth
sacred tusk
#

im trying to find the thing on my keyboard

sacred tusk
simple jacinth
#

bro im freaky if you don't send it

sacred tusk
#
a
#

okay got it

random blaze
#

omg

simple jacinth
#

bro im gonna legit while true do without any task.wait right now bro

random blaze
#

lol

sacred tusk
#

hi so I got muted for a minute for sending the code

simple jacinth
#

just send it through dms bro

#

send it my dm

random blaze
#

me to

#

too

simple jacinth
#

im freaking it bro

sacred tusk
#
local runService = game:GetService("RunService")
local part = script.Parent

local speed = 0.1
local distances = {}

part.Touched:Connect(function(hit)
    print("touched", hit.Name)
end)

runService.Heartbeat:Connect(function()
    --find closest player
    
    local smallestDistance = math.huge
    local closestPlayer = nil
    
    for _, player in pairs(game.Players:GetPlayers()) do
        local playerDistance = (player.Character.PrimaryPart.Position - script.Parent.Position).Magnitude
        distances[player] = playerDistance
    end
    for player, distance in distances do
        if distance < smallestDistance then
            smallestDistance = distance
            closestPlayer = player
        end
    end
    
    part.CFrame = CFrame.new(part.Position, closestPlayer.Character.HumanoidRootPart.Position) * CFrame.Angles(0, math.rad(90), 0)
    part.CFrame *= CFrame.new(speed, 0, 0)
    speed *= 1.0002
end)
#

I changed some words that were apparently blocked

random blaze
#

syntax error

#
  • inf yield
#

CHECK YOUR OUTPOST

sacred tusk
#

VRO

simple jacinth
#

bro what the fuck

sacred tusk
#

did you read what I need help with? 😭

simple jacinth
#

i havent even find the shit yet

random blaze
#

BRO

sacred tusk
#

the code is WORKING

#

it's just not detecting collissions with ONE PART

random blaze
#

but you don t like error

sacred tusk
#

no errors

#

0 errors

simple jacinth
#

ok imma try this on rblx studio rq

sacred tusk
#

most of the code working perfectly

#

the part is anchored

random blaze
#

smallestDistance = Distance

sacred tusk
#

and has cancollide on

sacred tusk
sacred tusk
#

that part isn't the problem

#

that part is working perfectly

random blaze
#

i never said it was the problem

#

that was a typo

sacred tusk
#

then why mention it 😭

random blaze
#

i starded copying from there

#

-__

sacred tusk
#

@simple jacinth get freaky on him

random blaze
#

WHAT DID I EVEN DO

#

YOU KNOW WHAT IM NOT HELPING YOU BRO

sacred tusk
#

alright alright sorry

#

prcaiteMaster9000

random blaze
#

oaky ):<

simple jacinth
#

okay wait

#

i think i know how this works

sacred tusk
#

enlighten us zark kun

simple jacinth
#

for me its not even detecting the baseplate

#

it only detects the parts from the player

random blaze
#

use humanoidrootpart

sacred tusk
#

it was detecting the baseplate when I tried it

random blaze
#

the problem is at primary

#

do findfirstchild("HumanoidRootPart")

sacred tusk
#

that part is working as it should

#

everything inside heartbeat is working as it should

#

the problem is on in the touched function

simple jacinth
#

uh

#

we just ignore the red error on the console right

random blaze
#

just add the partname

#

that u want to detect specificly

simple jacinth
#

okay

#

so uh

#

i searched on roblox studio forum

#

it says

#

using cframe

#

is kind of unreliablel

#

for touch shits

#

diddyahh

random blaze
#

use the new roblox studio Ai

simple jacinth
#

instead use bodyvelocity

#

its gonna make the part movement much smoother

#

and i think its gonna be able to detect touches

sacred tusk
#

alright but one thing

simple jacinth
#

from anywhere

random blaze
#

lolololololol

sacred tusk
#

I did a little test just now

simple jacinth
#

yea yea

sacred tusk
#

unanchored the parts that I want it to collide with

random blaze
#

omagawd

sacred tusk
#

and it detected the touches but only when it touched the sides

random blaze
#

OMAGAWD

sacred tusk
#

not from the front

#

why is roblox studio this way

random blaze
#

BECAUSE IT IS THE BEST

sacred tusk
#

ok PrcaiteMaster9000

#

so, body velocity

#

and set the velocity to point to the closest player

#

thank you sir zark

simple jacinth
#

dont thank me

#

try it first

#

💀

#

bro i master in ui not these shit

#

ggez

#

or linearvelocity

#

dont really know about velocity doe

#

just search in the dev forum fr

#

learn the properties

sacred tusk
#

actually i thnk body velocity is deprecated

simple jacinth
#

yeah yeah

#

linear velocity prob

sacred tusk
#

I think the alternative is vector

#

thing

#

vectory velocity

simple jacinth
#

oh wait

drifting hatchBOT
#

studio** You are now Level 5! **studio

simple jacinth
#

yeah

sacred tusk
#

or vector force

simple jacinth
#

sorry

#

shit

sacred tusk
#

linear velocity

simple jacinth
#

maybe you should watch this to get a better understanding

sacred tusk
#

dw I've used them before

simple jacinth
#

alright -central cee

sacred tusk
#

I used bodyVelocity, it's working

#

who cares if its deprecated

simple jacinth
sacred tusk
#

thank you sir zark kun