So basically, this script is in StarterPack, and it makes it so when you press the R key down, you restore your full health by making the humanoid have that much health. the script is not working after i accidentally did something to it, and to change the version history to when it was working would be FATAL to the building portion of my game. any help please?
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)
if key == "R" then
Parent.Humanoid.Health = 100
end
end)
Well if you are going to do this on the client, use the UserInputService rather than the Mouse's KeyDown, as well as changing the deprecated connect to Connect
local player = game:GetService("Players").LocalPlayer game:GetService("UserInputService").InputBegan:Connect(function(input, event) if input.KeyCode == Enum.KeyCode.R then player.Character:WaitForChild("Humanoid").Health = 100 end end)
However, I would suggest doing this on the Server since then the Health will change for the player for all others to see, and not just the client the local script is being used for:
local remote = Instance.new("RemoteEvent") remote.Name = "HealthReload" remote.Parent = game:GetService("ReplicatedStorage") remote.OnServerEvent:Connect(function(player) player.Character:WaitForChild("Humanoid").Health = 100 end)
local remote = game:GetService("ReplicatedStorage"):WaitForChild("HealthReload") game:GetService("UserInputService").InputBegan:Connect(function(input, event) if input.KeyCode == Enum.KeyCode.R then remote:FireServer() end end)