Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with touching?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

I have a part and when something hits it, it grows. I want only if a human touches it.

x = game.Workspace.Cube.Part
settime= 1
mov = false

x.Touched:connect(function()
if mov == false then
mov=true
x.Size = x.Size + Vector3.new(1,1,1)
x.CFrame = CFrame.new(-8,-1,-3)
wait(settime)
mov=false
end
end)

1 answer

Log in to vote
-2
Answered by 8 years ago
x = game.Workspace.Cube.Part
settime= 1
mov = false

x.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then -- checks if theres a humanoid
if mov == false then
mov=true
x.Size = x.Size + Vector3.new(1,1,1)
x.CFrame = CFrame.new(-8,-1,-3)
wait(settime)
mov=false
end
end
end)

3
Firstly, explain your answers. Secondly, tab your code. HungryJaffer 1246 — 8y
0
@HungryJaffer I explained the only line that I added, sendonly tabbing code isn't even a rule so :3 User#5978 25 — 8y
Ad

Answer this question