The reason this isn't working is quite simple.
game.ReplicatedStorage.create.OnServerEvent:Connect(function(player, Action)
local hum = player.Character.Humanoid
StatsTable = {}
if Action == "RedEyes" then
table.insert(StatsTable,hum.WalkSpeed)
table.insert(StatsTable,hum.JumpPower)
Ori = player.Character.Head.face.Texture
player.Character.Head.face.Texture = "http://www.roblox.com/asset/?id=368111294"
hum.WalkSpeed = 32
hum.JumpPower = 100
powa.Value = 1
end
if Action == "RedOff" then
player.Character.Head.face.Texture = Ori
print(table.concat(StatsTable))
powa.Value = 0
end
end)
The two conditional statements check for different conditions. The "Action" parameter cannot be "RedEyes" and "RedOff" at the same time. Consequently, whenever the parameter is the string "RedEyes", the second conditional statement will not run and the table will not be printed. If it does, nothing will be printed, because you haven't added any elements to the table. The only time you add elements is in the first conditional statement's block, where you only add elements and don't print anything. If that block runs, then that means its condition was met, and that the second conditional statement's block will not run.
What I'm saying is that these two blocks of code:
if Action == "RedEyes" then
table.insert(StatsTable,hum.WalkSpeed)
table.insert(StatsTable,hum.JumpPower)
Ori = player.Character.Head.face.Texture
player.Character.Head.face.Texture = "http://www.roblox.com/asset/?id=368111294"
hum.WalkSpeed = 32
hum.JumpPower = 100
powa.Value = 1
end
if Action == "RedOff" then
player.Character.Head.face.Texture = Ori
print(table.concat(StatsTable))
powa.Value = 0
end
Will never both execute every time the RemoteEvent is fired by the client. Only one of the conditional statements can be met. One of them adds elements, and one of them prints the contents of the table.
To fix it, do this:
local StatsTable = {}
game.ReplicatedStorage.create.OnServerEvent:Connect(function(player, Action)
local hum = player.Character.Humanoid
if Action == "RedEyes" then
StatsTable = {}
table.insert(StatsTable,hum.WalkSpeed)
table.insert(StatsTable,hum.JumpPower)
Ori = player.Character.Head.face.Texture
player.Character.Head.face.Texture = "http://www.roblox.com/asset/?id=368111294"
hum.WalkSpeed = 32
hum.JumpPower = 100
powa.Value = 1
end
if Action == "RedOff" then
player.Character.Head.face.Texture = Ori
print(table.concat(StatsTable))
powa.Value = 0
end
end)
Setting the StatsTable variable to be empty every time the RemoteEvent is fired will make it so that it is always empty by the time table.concat is called on it, so nothing will be printed. I assume the first conditional statement's block should be clearing the contents and reentering them, and that the second should be printing them if they're already there.
1 comment
Ty!