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

Workspace.Script:9: '=' expected near '-' what do i do? please help

Asked by 8 years ago
local allPlayers = {}
for a,v in pairs(game.Players:Getchildren()) do 
table.insert(allPlayers,v)
end
local plrAmount = game.Players.Numplayers
local val1 = math.random(plrAmount)
local val2 
repeat
val2 - math.random(plrAmount)
wait(20)
until val2 ~=val1
allPlayers[val1].Character.Torso.CFrame = CFrame.new(0,0,0)
allplayers[val2].Character.Torso.CFrame = CFrame.new(665.995,7.1,-115.005)
math.randomseed(os.time())

it says Workspace.Script:9: '=' expected near '-' im not sure what to do

0
Post as Lua Code and try again. I don't know what line is what because it is unformatted. ModZombie 70 — 8y
0
would i put val2 = val2 - math.random(plrAmount) on the 7th line? berrythebetta 20 — 8y
0
Notice that "val2" is nil on line 7. Redbullusa 1580 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

val2 = val2 - math.random(plrAmount)

The variable is an integer value. To subtract, add, multiply, or divide a variable set as an integer, you must reset the variable. Resetting the variable is just like setting it in the first place. Except you do it like above, where you set the variable as itself, minus another variable, integer, or in this case, math.

Ad

Answer this question