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)
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