Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 5 years ago
Edited 5 years ago

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)




0
is this event intended to only damage one humanoid (like in a boss fight) or differing humanoids (like tools)? KicksForTricks56 36 — 5y
0
one humanoid EzireBlueFlame 14 — 5y
0
the player who fired, someone else? who DinozCreates 1070 — 5y
0
wait let me post the local script too EzireBlueFlame 14 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
 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)




0
ok here player.Name Lolamtic 63 — 5y
Ad

Answer this question