Hi, I've been trying to get the local player name into a function by getting it from a remote event but I could not because of indexing and return will not work. Here is my code:
local EnergyBar = `script.Parent
function getPlayerName(localplayer)
return localplayer
end
game.ReplicatedStorage.PlayerName.OnServerEvent:Connect(getPlayerName(localplayer))
EnergyBar.Activated:Connect(function()
print("test")
print(player.Name)
local character = game.Workspace[player.Name]
player.Character.Humanoid.Health = player.Character.Humanoid.Health + 100
player.Character.Humanoid.WalkSpeed = 21
wait(30)
player.Character.Humanoid.WalkSpeed = 16
end)`

1 comment
I think he's trying to get the player through the Remote Event