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
01 | function 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 |
10 | end |
11 | script.Parent.Handle.touched:Connect(onTouched) |
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 |
02 | local team = "None" -- Value for what team ball is on |
03 | function onTouched(hit) |
04 | if hit.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
05 | local PlayerTeam = hit.Team.Value -- What team player is on |
06 | if PlayerTeam ~ = team then -- If player team doesnt equal balls team |
07 | team = 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 |
15 | end |
16 | end |
17 | script.Parent.Handle.touched:Connect(onTouched) |