#how can i do M1 script for a character called "Brawler"? (that's a battleground game)
1 messages · Page 1 of 1 (latest)
i'm a roblox studio beginner and i want to make a punching script but idk how
i want to make a M1 for every character and "brawler" is my first character, but idk how to make M1 script for him
i did the animations tho
pls can anyone help?
white mode studio 🥀
its pretty easy making one
first you gotta make a local script that detects m1s and sends a FireServer() event whenever you click m1
then on a server script you detect that click with ``` OnServerEvent:Connect(function()
end)
and Clone a "hitbox" (its a part that u create yourself, then put it in replicated storage) everytime you click m1
make that hitbox not to collide and not anchored
what
nvm
anchored
and then whenever someone tahts not you touches that part, make its health decrease
then add cooldowns later
or whatever
what what
thats how you make a m1 script
@bold vortex
ill send u mine
to show you
m1 detector script : ```lua
local player = game.Players.LocalPlayer
local userInput = game:GetService("UserInputService")
local remoteEvent = game.ReplicatedStorage:WaitForChild("punches")
local fake = false
userInput.InputBegan:Connect(function(input, GameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if fake == false then
fake = true
remoteEvent:FireServer()
task.wait(0.5)
fake = false
end
end
end)
and my m1 is a bit longer and not pretty good
you should really think about improving this cause its not pretty good : ```lua
local RemoteEvent = game.ReplicatedStorage:WaitForChild("punches")
local hitZoneTemplate = game.ReplicatedStorage:WaitForChild("Damage zone")
local Players = game:GetService("Players")
local cooldowns = {}
RemoteEvent.OnServerEvent:Connect(function(plr)
local character = plr.Character
if not character then return end
local hrp = character:WaitForChild("HumanoidRootPart")
local forwardOffset = hrp.CFrame.LookVector * 3
local spawnPosition = hrp.Position + forwardOffset
local hitZone = hitZoneTemplate:Clone()
hitZone.CFrame = CFrame.new(spawnPosition, spawnPosition + hrp.CFrame.LookVector)
hitZone.Parent = workspace
game.Debris:AddItem(hitZone, 0.5)
hitZone.Touched:Connect(function(hit)
local characterHit = hit.Parent
if not characterHit then return end
local humanoid = characterHit:FindFirstChildOfClass("Humanoid")
if humanoid then
local hitPlayer = Players:GetPlayerFromCharacter(characterHit)
if hitPlayer == plr then
return
end
if cooldowns[humanoid] then
return
end
humanoid.Health -= 10
cooldowns[humanoid] = true
task.delay(0.4, function()
cooldowns[humanoid] = nil
end)
end
end)
end)
not perfect at all
and it can have many bugs
but its a start
that one you just put it in ServerScriptService
nani
** You are now Level 6! **
** You are now Level 1! **