How to get Character in normal Script

I am trying to get the character in a Normal Roblox Script, not a Local Script

I keep getting this error, here is the script and the error message
image
image

I tried doing more lines of code and separating the thing into 3 lines, but its all the same error

I am not a scripter, so I have very poor scripts, and not sure how all of it works fully. Anyone got any ideas?

Edit: The script right now is in ServerScriptService, and is being called upon by a RemoteEvent

1 Like

Use CharacterAdded event within a PlayerAdded event.

3 Likes

remote events are always passed the player who fired it, you can get their character like so.

my_remove_event.OnServerEvent:Connect(function(player)
    local character = player.Character
end)
2 Likes
game.Players.PlayerAdded:Connect(function(Player) 

       Player.CharacterAdded:Connect(function(Character)

   end)

end)

1 Like

I don’t now if there any more solutions but i usually do this:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		--Your code here and now u have the character
	end)
end)
2 Likes