Healing Tool/Script Not Working

Hello Everyone! I am Trying to Make A MedKit Tool Which when You Equip and Click On a Player,
It Heals the Player Whom you Clicked On.

But Unfortunately, My Scripts are Not Working.
Have A Look.


local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()


script.Parent.Equipped:Connect(function()
	local New = Instance.new("BoolValue")
	New.Parent = Player.Character:WaitForChild("Humanoid")
	New.Value = false
	New.Name = "NotToHeal"
	wait(0.2)
	Mouse.Button1Down:Connect(function()
		if Mouse.Target.Parent:FindFirstChild("Humanoid") then
			if Mouse.Target.Parent.Humanoid:FindFirstChild("NotToHeal") then
				print("Cant Heal")
			else
				local ClickedPlayer = game.Players:GetPlayerFromCharacter(Mouse.Target.Parent)
				print(ClickedPlayer)
				game.ReplicatedStorage.HealPlayer:FireServer(ClickedPlayer)
			end
		end
	end)
end)

script.Parent.Unequipped:Connect(function()
	if Player.Character.Humanoid:FindFirstChild("NotToHeal") then
		Player.Character.Humanoid.NotToHeal:Destroy()
	end
end)

The Above Script is A Local Script Inside the Tool.
When i click On another Player, It Prints the Player whom I clicked on And Fires a Remote Event.
Now The Problem is that Before Firing the Remote Event,
I Print the Player whom i clicked on. Now it Prints The Player Such as "Player 2".
But When I Try to print The player again on the Server Where the Remote Event is recieved, It prints my Name.

How do i fix this?

game.ReplicatedStorage.HealPlayer.OnServerEvent:Connect(function(playerToHeal)
	print(playerToHeal)
	playerToHeal.Character:WaitForChild("Humanoid").Health = playerToHeal.Character.Humanoid.Health + 35
	game.Workspace.Sounds.Healed:Play()
	
	local SignClone = game.ServerStorage.HealingUI:Clone()
	SignClone.Parent = playerToHeal.Character.UpperTorso
	wait(2)
	SignClone:Destroy()
end)

RemoteEvents take a player argument (who fired the remote) as the first argument.
So in your case it would be
game.ReplicatedStorage.HealPlayer.OnServerEvent:Connect(function(plr, playerToHeal)

1 Like

Ohh! Thanks! I tested It and it worked!

1 Like

No problem. I used to make the same mistake too

1 Like