Hi, I've made a script to change a players Health and/or Max health when they chat. I tried to make a prefix for it, and that may be a problem as this is my first time attempting to make a prefix.
Here is the Script:
game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
if msg == "MaxHealth" .. tonumber(msg) then
player.Character.Humanoid.MaxHealth = tonumber(msg)
end
if msg == "Health" .. tonumber(msg) then
player.Character.Humanoid.Health = tonumber(msg)
end
end)
end)
Thanks.

2 comments
Thanks, this worked perfectly, Would it also work if I added a "=" after the "health", for example if I edited the code so it said "if (string.lower(string.sub(msg, 1, 11)) == "maxhealth = ") would it work or does the "=" at the end change the Strong?
string.sub(msg, 1, 11) gives you the first 11 characters of your message, and "maxhealth = " has 12 characters (counting spaces), so if you wanted it to work you should change that 11 to a 12 and it should work! But also keep in mind that the number starts at the 13th character, so you'd also have to change number = tonumber(string.sub(msg, 13))