Player presses key, if touching a certain part with a certain name then continue code, how would I do this?
--doctorbenny2011 09/04/2016 15:45GMT
istouching = false
local Player = game.Players.LocalPlayer
repeat wait(.01) until Player.Character
local Mouse = Player:GetMouse()
local Animated = false
Player.Character["Left Leg"].Touched:connect(function(hit)
if hit then
if hit.Name == "Matress" then
istouching = true
elseif hit.Name ~= "Matress" then
istouching = false
end
end
end)
Mouse.KeyDown:connect(function(key)
local Animation = Instance.new("Animation")
if key == "c" then
if istouching == true then
game.Workspace.BasePlate.CFrame = game.Workspace.BasePlate.CFrame * CFrame.Angles(0,1,0)
end
end
end)

1 comment
But this local script will be inside the PlayerGui, I'm trying to check if the player is touching a part with a specific name FROM the players PlayerGui.