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

01function onTouched(hit)
02 if hit.Parent:FindFirstChild("Humanoid") ~= nil then
03  script.Parent.Parent=workspace
04   wait()
05    script.Parent.Parent=hit.Parent
06     script.Disabled = true
07      wait(2.5)
08       script.Disabled = false
09    end
10end
11script.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

01-- Assuming that you have a string value inside of the player that determines what team they are on
02local team = "None" -- Value for what team ball is on
03function onTouched(hit)
04 if hit.Parent:FindFirstChild("Humanoid") ~= nil then
05local PlayerTeam = hit.Team.Value -- What team player is on
06if PlayerTeam ~= team then -- If player team doesnt equal balls team
07team = hit.Parent.Team.Value -- Makes ball team current players team
08  script.Parent.Parent=workspace
09   wait()
10    script.Parent.Parent=hit.Parent
11     script.Disabled = true
12      wait(2.5)
13       script.Disabled = false
14    end
15end
16end
17script.Parent.Handle.touched:Connect(onTouched)
Ad

Answer this question