Player presses key, if touching a certain part with a certain name then continue code, how would I do this?
01 | --doctorbenny2011 09/04/2016 15:45GMT |
02 |
03 | istouching = false |
04 | local Player = game.Players.LocalPlayer |
05 | repeat wait(. 01 ) until Player.Character |
06 | local Mouse = Player:GetMouse() |
07 | local Animated = false |
08 |
09 | Player.Character [ "Left Leg" ] .Touched:connect( function (hit) |
10 | if hit then |
11 | if hit.Name = = "Matress" then |
12 | istouching = true |
13 | elseif hit.Name ~ = "Matress" then |
14 | istouching = false |
15 | end |
You might be able to use Touch and TouchEnded.
01 | tv = 0 |
02 | function pint() |
03 | print ( "touch" ..tv) |
04 | tv = tv + 1 |
05 | end |
06 | function upint() |
07 | print "touch ended" |
08 | end |
09 | script.Parent.Touched:connect(pint) |
10 | script.Parent.Touched:connect(upint) |
something like that should work. It won't work very well, but it will work.
01 | --doctorbenny2011 09/04/2016 15:45GMT |
02 |
03 | istouching = false |
04 | local Player = game.Players.LocalPlayer |
05 | repeat wait(. 01 ) until Player.Character |
06 | local Mouse = Player:GetMouse() |
07 | local Animated = false |
08 |
09 | --UserInputFunction |
10 | Matress.Touched:connect( function (touched) --Detects when touched & define matress |
11 | if touched.Parent.Humanoid = = true then |
12 | istouching = true |
13 | end |
14 | end |
15 |