Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can i detect if parts are touching?

Okay, so i know how to detect if parts have touched, but i'm not sure how to detect if parts are touchING, i'm making the player's controller (that is if they are playing on controller) vibrate as long as a specific part is touching another anchored part, say, a block of ground, i used .Touched but i forgot that it only worked at the moment of the two parts touching, and didn't continue anymore (the vibrating is meant to be constant, so this doesn't work as it just stops after a small amount of time, i am unsure if i also have to detect when the parts stop touching to stop the vibration, so if anyone could help me out with that too then that'd be awesome

tl;dr: dont know how to detect constant contact between parts, help pls

1 comment

2

you can have boolean variable which will be set to true when .Touched fires and .TouchEnded would set it back to false, this event fires when you stop touching part.

3 answers

local ps = game:GetService("Players")
ps.PlayerAdded:Connect(function(plr)
local val = Instance.new("BoolValue",plr.Character) -- set the parent to anything
local part = workspace.Map.VibaratePart
part.Touched:Connect(function(t)
if t.Parent == plr.Character then
val = true
part.TouchEnded:Connect(function()
val = false
end)
end)
end
end)

1 comment

0

then add nifty script to detect when its true or false

(answered by imKirda through comments, perfectly solves the issue i was having)

This discussion is preserved as it was. New answers, comments, and votes are closed.