There are no syntax problems, but it is printing 'touching workspace and not player' when it is touching player and I don't know how I can counteract that.
My main question is how do I detect all the blocks that are touching the handle (which is a tool in the starterpack) and make it print something, and if it is touching a player (me) it will do nothing? It is printing touching workspace (which refers to blocks in workspace) and not player, but it is printing that because it is touching player.
Tool = script.Parent Tool.RequiresHandle = true Tool.GripPos = Vector3.new(0,0,1.5) Tool.Handle.Touched:Connect(function(hit) if hit.Parent and not hit.Parent:FindFirstChild("Humanoid") then print("touching workspace & not player") else print("touching player") end end)
Try:
local Tool = script.Parent Tool.RequiresHandle = true Tool.GripPos = Vector3.new(0,0,1.5) -- if this isn't a local script change this local Player = game.Players.LocalPlayer Tool.Handle.Touched:Connect(function(hit) if hit.Parent and hit.Parent:FindFirstChild("Humanoid) then if not hit:IsDescendantOf(Player.Character) then print("Touched a part that's not the local player") print(hit.Name) -- to confirm what part is being hit end end end)
Well, actually you code is right. The problem is the grip-pos. Since as far as the handle is concerned its touching the base-plate/parts. So in actuality its touching the ground or a part. Not the player.