Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I make a Anti Team Steal?

There is a basketball for a roblox basketball game, the steal script works fine, but the problem is my own teammate is stealing the ball. How can I stop my teammate from stealing the ball but allow the enemy team to steal it? Location: http://prntscr.com/jnq732

function onTouched(hit)
 if hit.Parent:FindFirstChild("Humanoid") ~= nil then
  script.Parent.Parent=workspace
   wait()
    script.Parent.Parent=hit.Parent
     script.Disabled = true
      wait(2.5)
       script.Disabled = false
    end
end
script.Parent.Handle.touched:Connect(onTouched)



1 answer

✓ Accepted answer

You can make the ball detect which team its being held by. When the ball enters a players hand, make it detect which team that player is on, then do something along the line of

-- Assuming that you have a string value inside of the player that determines what team they are on
local team = "None" -- Value for what team ball is on
function onTouched(hit)
 if hit.Parent:FindFirstChild("Humanoid") ~= nil then
local PlayerTeam = hit.Team.Value -- What team player is on
if PlayerTeam ~= team then -- If player team doesnt equal balls team
team = hit.Parent.Team.Value -- Makes ball team current players team
  script.Parent.Parent=workspace
   wait()
    script.Parent.Parent=hit.Parent
     script.Disabled = true
      wait(2.5)
       script.Disabled = false
    end
end
end
script.Parent.Handle.touched:Connect(onTouched)



This discussion is preserved as it was. New answers, comments, and votes are closed.