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

Strength to damage question.. ?

Asked by 2 years ago
Edited 2 years ago

How can I make it so that the strength turns into damage?

(PLEASE READ BEFORE ANSWERING)

Example:

If I have exactly 18,674,123 strength then I also deal 18,674,123 damage

I have tried so many different things but I cannot pinpoint exactly what I need, I don't have a damage script currently and the only reason the tool does damage is because of the 2 scripts i took from the roblox sword model in the free models.

Notes: The remote that gives strength - "Swing" The Strength value - "Strength" is a NumberValue (If it is an intvalue it breaks a few of my scripts) Tool that needs to be held in order to gain strength - "Knife"

Here are the scripts used for the game

Tool that gives strength:

LocalScript:

local module = require(script.Parent:WaitForChild("ModuleScript"))
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

script.Parent.Activated:Connect(function()
    module.Swing()
end)

ModuleScript

local module = {}
local replicatedStorage = game:GetService("ReplicatedStorage")

function module.Swing()

    replicatedStorage.Remotes.Swing:FireServer()

end

return module

Script that gives you strength everytime you click with the tool in hand

(Contains one of the gamepasses used in my game)

Remotes:

local replicatedStorage = game:GetService("ReplicatedStorage")
local MPS = game:GetService("MarketplaceService")
local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData")

local cooldown = 0.5

replicatedStorage.Remotes.Swing.OnServerEvent:Connect(function(player)

    if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end

    local debounce = remoteData[player.Name].Debounce

    if not debounce.Value then

        debounce.Value = true

        wait(cooldown)

        debounce.Value = false

        local ownGP
        pcall(function() -- I'm not sure if you need this, this is just how I was taught..
            ownGP = MPS:UserOwnsGamePassAsync(player.UserId,  28479471) -- replace 4 with your game pass ID
        end)

        if ownGP then -- If player has gamepass
            player.leaderstats.Strength.Value += (15*2)
        elseif not ownGP then -- If player doesn't have gamepass
            player.leaderstats.Strength.Value += 15

        end

    end

end)

0
You can modify the roblox sword script to find where it deals damage to the target that it's hitting, and then make that modified by the players damage. Maybe you could use :GetPlayerFromCharacter() to get the player from the Tool's Parent, and then take that damage value from there. Frometa1998 35 — 2y

Answer this question