I have this script, and it works fine (for the most part) but when I touch it, it senses the hats also, how would I make it only take the characters name?
function onTouch(hit) if game.Workspace.Positions.First.Value == "" then game.Workspace.Positions.First.Value = hit.Parent.Name elseif game.Workspace.Positions.Second.Value == "" then game.Workspace.Positions.Second.Value = hit.Parent.Name elseif game.Workspace.Positions.Third.Value == "" then game.Workspace.Positions.Third.Value = hit.Parent.Name wait(1) game.Workspace.Positions.Last.Value = true end end script.Parent.Touched:connect(onTouch)
Very simple solution, an if statement checking if the touch part's classname is not a hat, and it's parent has a humanoid (Just to make sure it's a character touching)
It could be done as follows:
function onTouch(hit) if not hit:IsA("Hat") and hit.Parent:findFirstChild("Humanoid") then if game.Workspace.Positions.First.Value == "" then game.Workspace.Positions.First.Value = hit.Parent.Name elseif game.Workspace.Positions.Second.Value == "" then game.Workspace.Positions.Second.Value = hit.Parent.Name elseif game.Workspace.Positions.Third.Value == "" then game.Workspace.Positions.Third.Value = hit.Parent.Name wait(1) game.Workspace.Positions.Last.Value = true end end end script.Parent.Touched:connect(onTouch)
Hope it helps!