Basically im trying to make a bladeball test, and i’ve made it go to a randomplayer in the game, but i want it to not be the deflectingplayer so i made a variable for the deflectingplayer, and said if randomplr ~= deflectingplayer then it will work, but you sometimes have to try many times to make it not be the deflecting player
Not really, but the way you’re getting a random player might be the problem.
The way to solve this is to make an array of all available players, then remove the deflecting player from that array before taking a random player from that array.
Or in other words, make a list of all other players except the deflecting player, then take the random player from that list. The way I’d do it would be something like:
local RNG = Random.new()
local Players = game:GetService("Players")
local function getRandomPlayer()
local playerList = {}
-- generate the list
for _,player in ipairs(Players:GetPlayers()) do
if player ~= DEFLECTING_PLAYER then
table.insert(playerList, player)
end
end
-- get random from that list
return playerList[RNG:NextInteger(1, #playerList)]
end