How do I make punching damage increase according to leaderstats? [closed]
I made the punch but how do you make the damage increase on the increase of leaderstats? My leaderstats is "Pounds". So like if you have 50 pounds how do you make the damage increase? The following script is the punch script in ServerScriptStorage :
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
02 | local punchEvent = Instance.new( "RemoteEvent" , ReplicatedStorage) |
03 | punchEvent.Name = "PunchEvent" |
05 | local animations = { 2837703681 , 2837724814 } |
06 | local function onPunchFired(plr) |
07 | local char = game.Workspace:FindFirstChild(plr.Name) |
08 | local humanoid = char.Humanoid |
09 | local animation = Instance.new( "Animation" ) |
10 | local picked = math.random( 1 , #animations) |
12 | local animTrack = humanoid:LoadAnimation(animation) |
14 | local dmgScript = script.DmgScript:Clone() |
16 | dmgScript.Parent = char.RightHand |
17 | elseif picked = = 2 then |
18 | dmgScript.Parent = char.LeftHand |
20 | dmgScript.Disabled = false |
25 | punchEvent.OnServerEvent:Connect(onPunchFired) |
his is the damage script inside of the punch script and as said I need help increasing the damage on the increase of Pounds.
01 | script.Parent.Touched:Connect( function (hit) |
02 | local char = hit.Parent |
03 | local hum = char:FindFirstChild( "Humanoid" ) |
04 | if hum and char.Name ~ = script.Parent.Parent.Name then |
05 | hum.Health = hum.Health - 10 |
06 | script.Disabled = true |
08 | script.Disabled = false |
Here is the LocalScript to tell what key to press to punch in StarterCharacterScripts:
01 | local UserInputService = game:GetService( "UserInputService" ) |
02 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
03 | local punchEvent = ReplicatedStorage:WaitForChild( "PunchEvent" ) |
07 | local function punch(inputObject, gameProcessed) |
08 | if inputObject.KeyCode = = Enum.KeyCode.Q and ready then |
09 | punchEvent:FireServer() |
16 | UserInputService.InputBegan:Connect(punch) |