Hello, does anyone know how to get the player’s own team through the tool using server script? I tried to use many ways to get my player but couldn’t. I just need to find out my player’s team through the toolusing server script. Please, can someone help me?
debounce = false
local CanAttack = false
local Sword = script.Parent.Parent
local HitBox = script.Parent
local MyPlayer = How?
Sword.Activated:Connect(function(Activated)
if CanAttack == false then
CanAttack = true
end
end)
HitBox.Touched:Connect(function(Hit)
if CanAttack == true then
if debounce == false then
local HitHumanoid = Hit.Parent:FindFirstChild("Humanoid")
local HitedPlayer = game.Players:GetPlayerFromCharacter(Hit.Parent)
if HitHumanoid then
if MyPlayer.Team ~= HitedPlayer.Team then
HitHumanoid:TakeDamage(12.5)
debounce = true
wait(0.875)
CanAttack = false
debounce = false
end
end
end
end
end)
debounce = false
local CanAttack = false
local Sword = script.Parent.Parent
local HitBox = script.Parent
local MyPlayer = script.Parent.Parent:WaitForChild("MyPlayer")
MyPlayer.Changed:Connect(function()
MyPlayer.Value = MyPlayer.Value
end)
print(MyPlayer.Value)
Sword.Activated:Connect(function(Activated)
if CanAttack == false then
CanAttack = true
end
end)
HitBox.Touched:Connect(function(Hit)
if CanAttack == true then
if debounce == false then
local HitHumanoid = Hit.Parent:FindFirstChild("Humanoid")
local HitedPlayer = game.Players:GetPlayerFromCharacter(Hit.Parent)
if HitHumanoid then
print(MyPlayer.Value)
if MyPlayer.Value.Team ~= HitedPlayer.Team then
HitHumanoid:TakeDamage(12.5)
debounce = true
wait(0.875)
CanAttack = false
debounce = false
end
end
end
end
end)
value script -
game.Players.PlayerAdded:Connect(function(Player)
local Value = script.Parent
Value.Value = Player.Name
end)
debounce = false
local CanAttack = false
local Sword = script.Parent.Parent
local HitBox = script.Parent
local Character = script.Parent.Parent.Parent
local MyPlayer = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent)
Sword.Activated:Connect(function(Activated)
if CanAttack == false then
CanAttack = true
end
end)
HitBox.Touched:Connect(function(Hit)
if CanAttack == true then
if debounce == false then
local HitHumanoid = Hit.Parent:FindFirstChild("Humanoid")
local HitedPlayer = game.Players:GetPlayerFromCharacter(Hit.Parent)
if HitHumanoid then
if MyPlayer.Team ~= HitedPlayer.Team then
HitHumanoid:TakeDamage(12.5)
debounce = true
wait(0.875)
CanAttack = false
debounce = false
end
end
end
end
end)