Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make a Anti Team Steal?

Asked by 6 years ago

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

Log in to vote
1
Answered by 6 years ago

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)



Ad

Answer this question