Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make my server script damage a Humanoid when the remote event is fired?

I have been struggling with this for days and i dont know what to do. The serverscript code is running fine but i need help finding out how to make it damage a humanoid

 local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punch = Instance.new("RemoteEvent", ReplicatedStorage)
punch.Name = "PunchEvent"


 function onpunch(player)
print("start")

end		
	

	
	
	
	
	punch.OnServerEvent:Connect(onpunch)
	
	
	
	

this is the local script

local rep = game:GetService("ReplicatedStorage")
local punch = rep:WaitForChild("PunchEvent",1)
local user = game:GetService("UserInputService")
local Player = game:GetService("Players")
local player = game.Players.LocalPlayer
local character = player.Character
local human = script.Parent
local humanoid = character.Humanoid
local hmd = character:WaitForChild("Humanoid") 
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://2642258675"
local Q = Enum.KeyCode.Q
local function IsQkeydown(Q)	
	
	return user:IsKeyDown(Q)	end 

local function Input (Input,InputObject)
	if not IsQkeydown(Q) then
		
	else
		print("hit")
		 local AnimationTrack = hmd:LoadAnimation(anim)
		AnimationTrack:Play()
		punch:FireServer(print("Safe"))
			wait(0.1)
			if not IsQkeydown(Q) then
				
			 end
			
		end
		
		  end
		
	
	
			
		
	
		
	
			
		
	user.InputBegan:Connect(Input)




4 comments

0

is this event intended to only damage one humanoid (like in a boss fight) or differing humanoids (like tools)?

0

one humanoid

0

the player who fired, someone else? who

0

wait let me post the local script too

1 answer

 local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punch = Instance.new("RemoteEvent", ReplicatedStorage)
punch.Name = "PunchEvent"


 function onpunch(player)
workspace[player.Name].Humanoid:TakeDamage(10) 

end     






    punch.OnServerEvent:Connect(onpunch)




1 comment

0

ok here player.Name

This discussion is preserved as it was. New answers, comments, and votes are closed.