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

How can I stop team from stealing their own teammate ball?

Asked by 6 years ago
Edited 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
0
Answered by 6 years ago

To make your teammate not steal the ball, you could store an array or a folder that includes your teammates' names (i.e local array = {"Player1","Player2"})

I don't know the value of HandValue. I am guessing it is an object value that says which team or player has the ball(please correct me if I my statement is incorrect). So if it is, you could use that to insert the team in the team array.

Here is how your code would look. By the way, please indent when making code, it makes your code look neat.

local team = {} -- this is where your teammates' names are stored
function onTouched(hit)
    if hit.Parent:FindFirstChild("Humanoid") then -- you don't have to have "~= nil" in here
        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) -- connect is deprecated. Use Connect. Roblox recommends developers to use syntaxes that are not deprecated

Hopefully this gave you an idea on how to make your teammates not steal the ball if your team has it.

-saSlol2436

0
Well thanks, but I cannot store player names because it's a public game with two teams of random players. And the HandValue is a Number Value, but I appreciate the help. I don't know what I should do at this point. hmmm IIApexGamerII 76 — 6y
0
Maybe you could use a RemoteFunction getting the two teams and it's players saSlol2436 716 — 6y
0
When the game is picking the teams and who is on it, you could use a remote function to get the team and the team in it saSlol2436 716 — 6y
Ad

Answer this question