I cant find anything about part touching part. Im talking about that if part touched another part then something happens . Plz write in answers. :-
To do a touched event, you could write it like this (as an anonymous function).
--// This script must be inside of your part script.Parent.Touched:Connect(function(hit) --// If the script's parent (the part) is touched then it will connect this function and log what hit it (logged through the "hit" parameter). -- Put what happens here (i.e. transparency changes, brickcolor changes, etc. end)
Code you need:
function OnTouch(hit) --your code here script.Parent.Touched:Connect(OnTouch)
Example of use (my fire script):
local val = 0 function OnTouch(hit) local head = hit.Parent:FindFirstChild("Head") local human = hit.Parent:FindFirstChild("Humanoid") if human ~= nil then local GC = hit.Parent:GetChildren() for i, v in pairs(GC) do if v:IsA("BasePart") then if v:FindFirstChild("FireEmmiter") == nil then local Particle = script.Parent:FindFirstChild("FireEmmiter") local ParticleClone = Particle:Clone() ParticleClone.Parent = v val = val + 1 if val == 16 then val = 0 while true do wait(0.025) human.Health = human.Health - 1 if human.Health == 0 then local s = hit.Parent:FindFirstChild("Shirt") local p = hit.Parent:FindFirstChild("Pants") for i, v in pairs(GC) do if v:IsA("Accessory") then v:ClearAllChildren() else if v:IsA("BasePart") then v.Material = Enum.Material.Slate v.Color = Color3.fromRGB(27, 42, 53) if s ~= nil then s:Destroy() if p ~= nil then p:Destroy() end end end end end end end end end end end end end script.Parent.Touched:Connect(OnTouch)
Closed as Not Constructive by itz_rennox, Torren_Mr, User#29913, zblox164, and JesseSong
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?