Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Expected identifier got equal?

The goal of the script is to get 1/4th of all players in the game, and round the numbers to a valid one.

The error occurs on line 6 and reads, Expected identifier, got '='

players = game:GetService('Players')

function ChosePlayer()
	local playerList = players:GetPlayers()
	local plrCount = #playerList % 4
	round(plrCount) = plrCount + 0.5 - (plrCount + 0.5) % 1
	return(playerList[math.random(round,#playerList)])
end

print(ChosePlayer())

What i need is, the error solved, so that i can make sure the number is being rounded properly!

Thank You

4 comments

0

Unless this a snippet of the actually code, then "round" doesn't exist; it isn't defined, thus your error. lol

0

i changed it to be plrCount, but it still gives the error

0

Is this all the code or do you have a round function somewhere?

0

You are trying to assign a value to a function returned value?

1 answer

Assuming round is actually a function that is defined in your script, you need to do it like this:

players = game:GetService('Players')

function ChosePlayer()
    local playerList = players:GetPlayers()
    local plrCount = #playerList % 4
    plrCount = round(plrCount + 0.5 - (plrCount + 0.5) % 1)
    return(playerList[math.random(round,#playerList)])
end

print(ChosePlayer())

The code is shaky - I don't know if you want to have the 'round(plrCount)' seperate from the actual plrCount, but if not, this code would work. You are unable to define what a variable is when declaring it's name, for example:

local randomFloat = 3.14
math.floor(randomFloat) = randomFloat

would NOT work, as you're trying to declare the name of the variable to be a function being called. It would work if you did it as this, however:

local randomFloat = 3.14
randomFloat = math.floor(randomFloat)

For more info, check the Wiki's explanation on variables here: http://wiki.roblox.com/index.php?title=Variable

This discussion is preserved as it was. New answers, comments, and votes are closed.