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

How do I make the punch damage increase on the increase of leaderstats?

Asked by 5 years ago

My leaderstats is "Pounds" . Here is the punch script in ServerScriptStorage

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

local animations = {2837703681, 2837724814} local function onPunchFired(plr) local char = game.Workspace:FindFirstChild(plr.Name) local humanoid = char.Humanoid local animation = Instance.new("Animation") local picked = math.random(1, #animations) animation.AnimationId = "http://roblox.com/asset/?id="..animations[picked] local animTrack = humanoid:LoadAnimation(animation) animTrack:Play() local dmgScript = script.DmgScript:Clone() if picked == 1 then dmgScript.Parent = char.RightHand elseif picked == 2 then dmgScript.Parent = char.LeftHand end dmgScript.Disabled = false wait(0.4) dmgScript:Destroy() end

punchEvent.OnServerEvent:Connect(onPunchFired)

Here is the damage script in the punch script.

script.Parent.Touched:Connect(function(hit) local char = hit.Parent local hum = char:FindFirstChild("Humanoid") if hum and char.Name ~= script.Parent.Parent.Name then hum.Health = hum.Health - 10 script.Disabled = true wait(0.5) script.Disabled = false end end)

Here is the local script in StarterCharacterScripts to punch:

local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local punchEvent = ReplicatedStorage:WaitForChild("PunchEvent")

local ready = true

local function punch(inputObject, gameProcessed) if inputObject.KeyCode == Enum.KeyCode.Q and ready then punchEvent:FireServer() ready = false wait(0.5) ready = true end end

UserInputService.InputBegan:Connect(punch)

0
thank you ChefDevRBLX 90 — 5y
0
just multiply the damage by your leaderstats as the damage wookey12 174 — 5y

Answer this question