For an example, I want to set the Humanoid's WalkSpeed, I could just do this.
1 | hum.WalkSpeed = 100 |
But what if, a player sends a string to the server and want the server to set a certain property for the player?
For an example:
1 | local stringReceived = "WalkSpeed" |
2 |
3 | plrhum.stringReceived = 100 |
Still don't know how can I be able to do it. Or is it impossible?
server script
1 | local event = game.ReplicatedStorage.ChangeHum -- The Event |
2 |
3 | event.OnServerEvent:Connect( function (plr,property,num) -- the fired function that gave the property and number from localscript |
4 | plr.Character.Humanoid [ property ] = num |
5 | end ) |
local script
1 | local event = game.ReplicatedStorage.ChangeHum -- The Event |
2 |
3 | event:FireServer( "WalkSpeed" , 1000 ) -- gives the property and number |
Yes. obj.index
is sugar for obj["index"]
. However the former only works if it is a valid identifier. obj.+]^}
is not a valid identifier. It must therefore be indexed with square brackets. obj["+]^}"]
.
plrhum[stringReceived]
is how you would do it.