For an example, I want to set the Humanoid's WalkSpeed, I could just do this.
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:
local stringReceived = "WalkSpeed" plrhum.stringReceived = 100
Still don't know how can I be able to do it. Or is it impossible?
server script
local event = game.ReplicatedStorage.ChangeHum -- The Event event.OnServerEvent:Connect(function(plr,property,num) -- the fired function that gave the property and number from localscript plr.Character.Humanoid[property]=num end)
local script
local event = game.ReplicatedStorage.ChangeHum -- The Event 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.