Im trying to make something happen when a player not on your team gets hit by your tool.
local tr = true
local Player = game.Players.LocalPlayer
local Tool = script.Parent
local Script = script
local Animation = Tool:WaitForChild("HitAnim1")
local HoldAnim = Tool:WaitForChild("HoldAnim")
local Character = Player.Character or Player.CharacterAdded:Wait()
local Hit1 = Character:FindFirstChildOfClass("Humanoid"):LoadAnimation(Animation)
local Hold = Character:FindFirstChildOfClass("Humanoid"):LoadAnimation(HoldAnim)
local PlayerEquiped = script.Parent.Parent.Parent
local Players = game:GetService("Players")
Tool.Equipped:Connect(function()
Hold:Play()
end)
Tool.Activated:Connect(function()
if tr == true then
Hit1:Play()
script.Parent.Slash:Play()
tr = false
wait(0.5)
tr = true
end
end)
Tool.Unequipped:Connect(function()
Hold:Stop()
end)
Tool.Hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
-- I need help here
local otherPlayer = Players:GetPlayerFromCharacter(hit.Parent)
if otherPlayer then
if otherPlayer.Team.Name ~= Player.Team.Name then
--do something here
end
end
end
end)