Skip to content

Commit 4f1e4b7

Browse files
authored
Update matchmaking/attributes-and-signals.md (#1272)
## Changes Issues I missed in #1271 - Fix formatting for line 229 - Instead of `error`, use `errorMessage`, as this collides with the [error](https://create.roblox.com/docs/reference/engine/globals/LuaGlobals#error) global (per [pcall](https://create.roblox.com/docs/reference/engine/globals/LuaGlobals#pcall) example) - Fixed invalid syntax (trying to assign to variable inside if statement) ## Checks By submitting your pull request for review, you agree to the following: - [x] This contribution was created in whole or in part by me, and I have the right to submit it under the terms of this repository's open source licenses. - [x] I understand and agree that this contribution and a record of it are public, maintained indefinitely, and may be redistributed under the terms of this repository's open source licenses. - [x] To the best of my knowledge, all proposed changes are accurate. ---------
1 parent f8620f8 commit 4f1e4b7

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

content/en-us/matchmaking/attributes-and-signals.md

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,12 @@ local DataStoreService = game:GetService("DataStoreService")
211211
local eloStore = DataStoreService:GetDataStore("PlayerElo")
212212

213213
function onMatchEnded(players: {Player}, winners: {Player}, losers: {Player})
214-
for _, player in players do
215-
local updatedElo = CalculateUpdatedElo(player, winners, losers)
216-
local success, errorMessage = pcall(function()
217-
eloStore:SetAsync(player.UserId, updatedElo)
218-
end)
219-
end
214+
for _, player in players do
215+
local updatedElo = CalculateUpdatedElo(player, winners, losers)
216+
local success, errorMessage = pcall(function()
217+
eloStore:SetAsync(player.UserId, updatedElo)
218+
end)
219+
end
220220
end
221221
```
222222

@@ -225,30 +225,28 @@ local MatchmakingService = game:GetService("MatchmakingService")
225225
local RunService = game:GetService("RunService")
226226

227227
if RunService:IsStudio() then
228-
-- Sets up initial attributes and schema for testing
229-
MatchmakingService:InitializeServerAttributesForStudio(
230-
{
231-
Level = "Advanced",
232-
Elo = 123.456,
233-
TrainingMode = true
234-
})
228+
-- Sets up initial attributes and schema for testing
229+
MatchmakingService:InitializeServerAttributesForStudio({
230+
Level = "Advanced",
231+
Elo = 123.456,
232+
TrainingMode = true
233+
})
235234
end
236235

237236
-- Retrieves the Level attribute
238-
local currentLevel, error = MatchmakingService:GetServerAttribute("Level")
239-
240-
if error then
241-
print(error)
237+
local currentLevel, errorMessage = MatchmakingService:GetServerAttribute("Level")
238+
if errorMessage then
239+
warn(errorMessage)
242240
else
243-
print("Current level: " .. currentLevel)
241+
print("Current level: " .. currentLevel)
244242
end
245243

246244
-- Updates the Level attribute value to Advanced
247-
local success, error = MatchmakingService:SetServerAttribute("Level", "Advanced")
245+
local success, errorMessage = MatchmakingService:SetServerAttribute("Level", "Advanced")
248246
if not success then
249-
print("Failed to update server attribute [Level] to [Advanced] due to error: " .. error)
247+
warn("Failed to update server attribute [Level] to [Advanced] due to error: " .. errorMessage)
250248
else
251-
print("Successfully set [Level] to [Advanced]")
249+
print("Successfully set [Level] to [Advanced]")
252250
end
253251
```
254252

@@ -386,21 +384,21 @@ local score = math.min(diff / max_relevant_difference, 1)
386384
The score is 1 when the server's attribute value (for example, Game Mode) is equal to the player's attribute value (for example, Preferred Game Mode). Otherwise, the signal score is 0.
387385

388386
```lua title="Joining player formula for server categorical signal"
389-
if server_{attribute_name} = joining_player_{attribute_name} then
390-
return 1
387+
if server_{attribute_name} == joining_player_{attribute_name} then
388+
return 1
391389
else
392-
return 0
390+
return 0
393391
end
394392
```
395393

396394
```lua title="Joining player example for server categorical signal"
397395
local server_GameMode = "Survival"
398396
local joining_player_GameMode = "Survival"
399397

400-
if server_GameMode = joining_player_GameMode then
401-
return 1
398+
if server_GameMode == joining_player_GameMode then
399+
return 1
402400
else
403-
return 0
401+
return 0
404402
end
405403
```
406404

@@ -409,19 +407,19 @@ end
409407
The score is 1 when the server's attribute value is equal to a constant value of true. Otherwise, the signal score is 0.
410408

411409
```lua title="Constant value formula for server categorical signal"
412-
if server_{attribute_name} = constant_value then
413-
return 1
410+
if server_{attribute_name} == constant_value then
411+
return 1
414412
else
415-
return 0
413+
return 0
416414
end
417415
```
418416

419417
```lua title="Constant value example for server categorical signal"
420418
local server_GameNotStarted = true
421419

422-
if server_GameNotStarted = true then
423-
return 1
420+
if server_GameNotStarted == true then
421+
return 1
424422
else
425-
return 0
423+
return 0
426424
end
427425
```

0 commit comments

Comments
 (0)