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

How can I make this knockback natural?

Asked by 7 years ago
game.ReplicatedStorage.SendRequest.OnServerEvent:Connect (function(Player,Target,Velocity,Damage)
    Target.leaderstats.Damage.Value = Damage
    if Target.Character.Torso:FindFirstChild("BV") == nil then
    BV = Instance.new("BodyVelocity")
    BV.Name = "BV"
    BV.Parent = Target.Character.Torso
    end
    Target.Character.Torso.BV.Velocity = Velocity
    wait (0.5)
    Target.Character.Torso.BV.Velocity = Vector3.new(0,0,0)
    Target.leaderstats.LastHit.Value = Player.Name
    end)

So, when i was making this script, i initially just wanted to apply a velocity to the player, and have roblox physics just slow the player back down to a halt.

It didn't work because some one told me to make the object "wake up". He meant put another force on it, then apply the velocity, but he reccomended using body velocitys.

I used them, and they make knockback unnatural. How can i "wake up" the player and just put a normal velocity on them?

0
A exploiter could just fire that event and damage 100 damage. Just saying. hiimgoodpack 2009 — 7y
0
I got FE on, besides, its a fighting game. If he takes time to try to rack up that damage, he will be killed in no time. User#17125 0 — 7y
0
You seem to misunderstand FE. FE means that clients can only do what you authorize them to do. An exploiter can fire any remoteevent/function. This is why if you have a remotevent that adds a catalog item in, you NEVER pass the ID, instead you pass a number with an ID linked to it, so the exploiter is limited to what would normally be possible. FE does stop typical hacks, but you can still build i lukeb50 631 — 7y
0
Well, may i ask then how can i prevent exploitation? This script REQUIRES this remote event, as this apart of a punch script. The player presses a key, the player does a punch, the server then handles knock back. Is this something i cant fix, because this seems just a flaw with the whole prinicple of my script. User#17125 0 — 7y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

In regards the exploitation why don't you just do


game.ReplicatedStorage.SendRequest.OnServerEvent:Connect (function(Player,Target,Velocity,Damage) if game.Workspace.PlayerInfo[Player.Name].Cooldown.Value = false then game.Workspace.PlayerInfo[Player.Name].Cooldown.Value = true local cooldownOff = coroutine.wrap(function(player, time) wait(time) game.Workspace.PlayerInfo[Player.Name].Cooldown.Value = false end) newThread(Player,3) -- 3 Seconds -- This bit here just makes a new mini-program called a coroutine that waits without making everything else stop. This means that you can do cooldown as well as not stopping this program. Just warning - Don't do too many of these, if you are likely to have a big game or something I would skip the coroutine and put the code inside it at the end. Target.leaderstats.Damage.Value = Damage if Target.Character.Torso:FindFirstChild("BV") == nil then BV = Instance.new("BodyVelocity") BV.Name = "BV" BV.Parent = Target.Character.Torso end Target.Character.Torso.BV.Velocity = Velocity wait (0.5) Target.Character.Torso.BV.Velocity = Vector3.new(0,0,0) Target.leaderstats.LastHit.Value = Player.Name end end)

For the actual original question I'm not sure, I haven't fiddled with Physics engines yet and I've only been at Lua for a week.

  • Edit: You need to make a new folder in Workspace called PlayerInfo and put a folder with each players name in that. Just do
game.Players.PlayerAdded:Connect(function(player)

local playerFolder = Instance.new("Folder")

playerFolder.Name = player.Name

playerFolder.Parent = game.Workspace.PlayerInfo
-- It is a lot less laggy to define the parent after all of the other stuff than to do Instance.new("Object",Parent)

local Cooldown = Instance.new("BoolValue")

Cooldown.Name = "Cooldown"

Cooldown.Value = false

Cooldown.Parent = playerFolder

end)
0
Should be secure now. Idk about the knockback. CodeOnRBLX 1 — 6y
Ad

Answer this question