Hi I just started making a weight lifting simulator and I’m trying to figure out how to make a combat system. For example: I have 1000 strength at someone else has 10, I’d do the most damage because I have 100x more strength. My issue is that if the damage is the strength variable, its overpowered if you have 0-10 strength as it can instant kill you. I’ve tried hum:Takedamage(dmg) but it didn’t work so I just went with the Strength variable until I could figure a solution out. Anybody have a solution?
local plr = game.Players.LocalPlayer
local strength = plr.leaderstats.Strength.Value
local debounce = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid')then
local h = hit.Parent.Humanoid
if debounce == true then
h.Health = strength
debounce = false
wait(1)
debounce = true
end
end
end)
if you want to deal damage to somebody, use a fireserver instead of a local script. As for making more damage, in the fireserver script use this:
remoteevent.OnServerEvent:Connect(function(player, strength, hit)
if hit.Parent:FindFirstChild("Humanoid") then
local startingdamage = 2
hit.Parent.Humanoid:TakeDamage(1 * (strength / 1.5))
end
The script isn’t working for me, it wont do damage. I tried to make a Fireserver() for the Remote Event as a local script but it wouldn’t do damage. I also tried changing the strength to Strength but it didn’t work either and created a remote event for it. Do you know what the problem is?
If you wanted to create a combat system base on variable damage, you will have two options, create a client side hitbox and send the hit info to the server using remote events to do the damage, or you can just do the everything on the server. My personal preference, along with many others, is to use the first option of creating a client side hitbox, because if you use a server sided hitbox, it results in a noticeable delay.
As for doing the damage according to a variable, you will have to do the damage server sided since a client can easily change any values on their client. All you have to do is use hit.Parent.Humanoid:TakeDamage(strength + starting damage + etc) on the server to do damage.
EDIT: Also, you should look into using raycasting or region3 for creating melee hitboxes, rather than OnTouched, because OnTouched can be rather finicky and slow.
So I’d make a remote function inside the Server-sided script inside the tool because the Hitbox-part is inside the tool so I would put the script inside the Hitbox right?
You would make a Tool that creates a client side hitbox, returns the hit info, send the hit information through a remote event by using its parameters to a server sided script, do sanity checks and execute the damage on to the hit.Parent.Humanoid base on your variables values.
If you really want to use Touched for making a hitbox, you could leave the hitbox in replicated storage and Clone() it and position it infront of the player. I still really don’t recommend using Touched Events for making hitboxs for melee combat though. Look into utilizing Region3 and Raycasting.