I am nearly done with my dash script. But I’ve thought of a couple of issues that I will face in the future in relation to my game that prevent me from finishing it. The game that I am working on is one where bombs
-
The code is vulnerable to exploiters, who will be able to disable cooldowns, change dash length to their will, or modify the
LinearVelocity
instance that creates the dash effect so that they can go anywhere. I would make this server sided, but I want my game to be as responsive as it can be. -
I want the
LinearVelocity
to be destroyed if a player is hit by an explosion, but the explosions are server sided—instances added by the client will be invisible to them.
I’ve been searching through the forums for answers and tried to apply the same logic from this post, but I couldn’t find any posts that could’ve helped, and the logic from the post hyperlinked I don’t believe can apply to this.
This is the script for it as of now.
local char = script.Parent
local rootPart = char.PrimaryPart
local humanoid = char:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local dashMult = 72 + (humanoid.WalkSpeed * 0.5)^1.25
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvents = replicatedStorage:WaitForChild("RemoteEvents")
local effectReplicationRemote = remoteEvents:WaitForChild("effectReplicationRemote")
function applyDashChange(linearVelocity, i)
local dashVelocity = Vector3.new(rootPart.CFrame.LookVector.X * (dashMult - (i * 10)), 0, rootPart.CFrame.LookVector.Z * (dashMult - (i * 10)))
linearVelocity.VectorVelocity = dashVelocity
end
local avaliableDashes = 3
local debounce = false
UIS.InputBegan:Connect(function(input, gameProcessed)
if not debounce then
if input.KeyCode == Enum.KeyCode.LeftShift and avaliableDashes > 0 then
avaliableDashes -= 1
local linearVelocity = Instance.new("LinearVelocity")
linearVelocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
linearVelocity.MaxAxesForce = Vector3.new(math.huge, 0, math.huge)
linearVelocity.VectorVelocity = rootPart.CFrame.LookVector * dashMult
linearVelocity.Attachment0 = Instance.new("Attachment")
linearVelocity.Attachment0.Parent = rootPart
linearVelocity.Enabled = true
linearVelocity.Parent = rootPart
for i = 1, 7 do
applyDashChange(linearVelocity, i)
task.wait(0.05)
if i == 7 then
linearVelocity.Attachment0:Destroy()
linearVelocity:Destroy()
end
end
end
end
end)