I want the attached script (which is inside a tool (see attached explorer image)) to check when a player clicks (with the tool equipped) then check if where they click is another player.
Code:
script.Parent.Equipped:Connect(function()
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:Connect(function()
if mouse.Target then
if mouse.Target.Parent:FindFirstChild("Humanoid") then
if game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then
local e = script.Parent.Punishment:Clone()
e.TargetPlayer.Value = mouse.Target.Parent.Name
e.Parent = game.Players.LocalPlayer.PlayerGui
end
end
end
end)
end)
Explorer: