I Need :GetPlayerFromCharacter() Help

Hello Developers, I’m trying to make a script that can reward a player when they kill the player in the game. My “Melee” weapons work fine, but I’m trying to figure out how to make the gun script work too. Here are my Scripts for my guns:

Local Script:

local maxammo = 10
local CoolDown = 0.23
local ammo = maxammo
local reloading = false
local plr = game.Players.LocalPlayer
local plrgui = plr:WaitForChild("PlayerGui")
local text = plrgui:WaitForChild("Ammo"):FindFirstChild("AmmoCount")

script.Parent.Equipped:Connect(function(Mouse)
	plrgui.Ammo.Enabled = true
	plrgui.Shop.Enabled = false
	local function reload()
		reloading = true
		wait(1)
		script.Parent.reload:Play() -- change reloadingsound to what ever your reload sound is named
		ammo = maxammo
		reloading = false
	end

	script.Parent.Activated:Connect(function()
		if ammo > 0 and not reloading then
			ammo = ammo - 1
			script.Parent.gunshot:Play() -- change gunshot to what ever your gun shot sound is named
			wait(CoolDown)
			local humanoid = Mouse.Target.Parent:FindFirstChild("Humanoid")
			if Mouse.Target.Parent:FindFirstChild("Humanoid") then
				script.Parent.DealDamage:FireServer(Mouse.Target.Parent, math.random(15,30)) -- change the 25 to what ever amount of damage you want to deal
				local player = game.Players.LocalPlayer
			end
		elseif reloading == false then
			reload()
			script.Parent.gunshot:Stop()-- change gunshot to what ever your gun shot sound is named
		end

		while wait() do
			text.Text = (ammo).." / "..tostring(maxammo)
		end
	end)

	local input = game:GetService("UserInputService")
	input.InputBegan:Connect(function(Key)
		if Key.KeyCode == Enum.KeyCode.R and reloading == false and ammo ~= maxammo then
			reload()
		end
	end)
	
	local input = game:GetService("UserInputService")
	input.InputBegan:Connect(function(Key)
		if Key.KeyCode == Enum.KeyCode.ButtonY and reloading == false and ammo ~= maxammo then
			reload()
		end
	end)
end)

script.Parent.Unequipped:Connect(function()
	plrgui.Ammo.Enabled = false
	plrgui.Shop.Enabled = true
end)

Normal Script (for RemoteEvent):

script.Parent.DealDamage.OnServerEvent:Connect(function(player, Target, Damage)
	Target.Humanoid:TakeDamage(Damage)
end)

If anyone out there, please help me find out how to make the :GetPlayerFromCharacter() Function work in my script.

Sincerely, papahetfan

I’m not sure what you mean but this is from what I understand:

-- put this inside the remote event script after line 2

if Target.Humanoid.Health <= 0 then
-- give player money (example: player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1000)
end
1 Like

Thank you for the help, have a good day.