Why I kept receiving this error message? And why the value not changing?
Error Message: 22:25:59.225 - Workspace.Events.Combat System.Movements.Power.current:9: attempt to index nil with 'Value'
01 | local event = game.ReplicatedStorage.GameEvents.Combat.Activate |
02 |
03 | event.current.OnServerEvent:Connect( function (player) |
04 | local c = player:findFirstChild( "current" ) |
05 | local main = player.PlayerGui.Stuff.Combat.current |
06 |
07 | local char = player.Character |
08 |
09 | c.Value = main.Value |
10 | print (c.Value") |
11 |
12 | end ) |
First, let's fix the indentation and replace "findFirstChild" with "FindFirstChild"(because the former is deprecated, I think):
01 | local event = game.ReplicatedStorage.GameEvents.Combat.Activate |
02 |
03 | event.current.OnServerEvent:Connect( function (player) |
04 | local c = player:FindFirstChild( "current" ) |
05 | local main = player.PlayerGui.Stuff.Combat.current |
06 | local char = player.Character |
07 |
08 | c.Value = main.Value |
09 | print (c.Value") |
10 | end ) |
And the only issue I really see is that you did this:
1 | print (c.Value") |
It should be this:
1 | print (c.Value) |