Why isn't the .Touched function working?
I've made a kind of simple script for boats and swimming, but I got stuck with the following problem: I've made a part that checks everything in front of you to make sure that nothing's blocking the way. All of a sudden the .Touched function doesn't seem to react, which causes the collision detection to not work. This is my code, I hope you can help:
01 | local bat = Instance.new( "Part" , script.Value.Value.Parent) |
02 | bat.FormFactor = "Custom" |
04 | bat.Size = Vector 3. new( 3 , 3 , 1 ) |
05 | bat.CFrame = plr.Character.Torso.CFrame*CFrame.new( 0 , 0 , -plr.Character.Torso.Size.Z) |
07 | bat.CanCollide = false |
09 | bat.CFrame = bat.CFrame*CFrame.new( 0 , 0 , - 0.02 ) |
10 | bat.Touched:connect( function (Part) |
11 | if Part.Parent ~ = bat.Parent then |
13 | elseif Part.Parent = = bat.Parent then |
14 | if Part.Name ~ = "Water" then |
23 | plr.Character.Torso.CFrame = plr.Character.Torso.CFrame*CFrame.new( 0 , 0 , - 0.2 ) |
Also the script is a LocalScript.