So I'm trying to make a script that heals the player your mouse is hovered over when you press a certain letter, but it's not working. The player isn't getting healed at all and no error messages are popping up. Any thoughts?
This code is in a local script.
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Players = game:GetService("Players")
local UserInput = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("HealPlayerDo")
UserInput.InputBegan:Connect(function(keycode)
if keycode.KeyCode == Enum.KeyCode.H and Player.TeamColor == BrickColor.new("Mulberry") then
local Hit = Mouse.Target
if Hit then
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
local PlayerHit = Players:GetPlayerFromCharacter(Hit.Parent)
local charr = Hit.Parent
local name = PlayerHit.Name
remoteEvent:FireServer(name)
end
end
end
end)
This code is in a regular script.
ReplicatedStorage = game:GetService("ReplicatedStorage")
remoteEvent = ReplicatedStorage:WaitForChild("HealPlayerDo")
function onCreatePart(player, namee)
game.Workspace.namee.Humanoid.Health = 100
local og = game.Lighting.healing.heal
local clone = og:Clone()
clone.Parent = game.Workspace.namee:WaitForChild("UpperTorso")
wait(3)
clone:Destroy()
end
remoteEvent.OnServerEvent:Connect(onCreatePart)
I have a RemoteEvent too called "HealPlayerDo"
