I created a little ground slam mechanic for a slightly more satisfying combat experience in my game. However, it’s not really working as I want it to. It got 2 problems:
- Shockwave is super delayed, and ruins ground slamming from the heights.
- It still damages and affects the player executing the action.
Here are the scripts involved:
Main script (local script)
local me = script.Parent
local player = game.Players.LocalPlayer
local anim = script.Animation
local track = player.Character:WaitForChild("Humanoid"):LoadAnimation(anim)
local keys = game:GetService("UserInputService")
local sound = script.dash
local event = game.ReplicatedStorage["dash sound"]
wait(1)
local hum = player.Character:WaitForChild("Humanoid")
sound.Parent = player.Character.HumanoidRootPart
local function getdown()
track:Play()
event:FireServer(sound)
player.Character.Humanoid.RootPart.Velocity = player.Character.Humanoid.RootPart.CFrame.LookVector * 0 + Vector3.new(0, -200, 0)
local slam = game.ReplicatedStorage.groundslam
if not player.Character:FindFirstChild("groundslam detector") then
slam:FireServer()
end
end
keys.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
if hum.FloorMaterial == Enum.Material.Air then
getdown()
end
end
end)
me.MouseButton1Up:Connect(function()
if hum.FloorMaterial == Enum.Material.Air then
getdown()
end
end)
Script for starting everything in the server side and setting up the slam detector (server script)
local event = game.ReplicatedStorage.groundslam
local detector = game.ServerStorage["groundslam detector"]
event.OnServerEvent:Connect(function(plr)
local clone = detector:Clone()
clone.Parent = plr.Character
local weld = Instance.new("Weld")
weld.Parent = plr.Character:WaitForChild("HumanoidRootPart")
weld.Part0 = plr.Character:WaitForChild("HumanoidRootPart")
weld.Part1 = clone
weld.C1 = CFrame.new(0, 10, 0)
end)
Script inside the slam detector part for spawning the shockwave model (server script)
local me = script.Parent
local shockwave = game.ServerStorage.shockwave
me.Touched:Connect(function(hit)
if hit:IsA("BasePart") then
local clone = shockwave:Clone()
clone.Parent = game.Workspace
clone:PivotTo(me.CFrame - Vector3.new(0, 2, 0))
game.ReplicatedStorage["ground slam sound"]:Fire(me.Position)
me:Destroy()
end
end)
The script placed inside the shockwave hitbox (invisible cylinder that cannot be seen in the vid but has a particle emitter) for damaging and blasting characters into the cosmos (server side)
local me = script.Parent
me.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent ~= me.Parent.Parent then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(1)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum:IsA("Humanoid") then
hum.RootPart.AssemblyLinearVelocity = hum.RootPart.CFrame.UpVector * 50
end
end
end
end)
I am suspecting that the shockwave delay is caused by all the events and the setting up of everything and other complicated stuff. I have no idea about what is going on with the player still being damaged by the shockwave.
Yes, it looks a bit too overpowered, but I will add limits after everything is alright.