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)
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)