Knockback Wall w/ Effect

Hey there!
I’m trying to achieve a similar effect as the Bloxy Awards and Egg Hunt 2018, with their so called “Zap Walls”.

Video below:

I know how to make the knockback, but how would I make the effect? Like at the spot the player touches a cylinder tweens size on the z and y axis on the surface of the part (where they are touching, like if they touch the back it appears on the back of the part)

1 Like

This could be achieved using the TweenService. You can use the TweenService to tween any size, position, number, or colour value the same way you tween UI elements. It would be as simple as triggering the tween at the position the player touches in the same part of the script that flings the player backwards.

i think i found a video on it on yt lemme get the link

If I had to assume, what I believe they did was when you touch that wall, it plays the animation and then a frame later adds a BodyVelocity to you with a velocity opposite of where you are looking with a certain strength which goes away after a few seconds

Edit: Okay I really should’ve looked at the video carefully, @BuilderBob25620 provides a great insight as to how it is done, would recommend doing what he mentioned

The wall you showed us does several things.

  1. It detects when the player hits the wall
  2. It creates and animates a ball at the position in which it is hit
  3. It makes the player counteract the force of gravity
  4. It rag-dolls the player
  5. It sends the player away from the wall

I am not able to tell whether or it kills the player from the video. However, even so, I feel this can be left up to you.

Step #1: Detection
This one is actually simple. While the Touched event isn’t that reliable, the wall is unmoving and the player doesn’t look to be moving that fast. Plus, other methods like Raycasting won’t work in this situation. So to set this you simply do something like this:

WallPart.Touched:Connect(function(hit)
	local character = hit.Parent
	local humanoid = character:FindFirstChildWhichIsA("Humanoid")
	if humanoid and character:IsA("Model") then -- Detects if the hit part is part of a character character
		-- Other code
	end
end)

But wait! The Touched event might fire multiple times for the same character! How do we prevent this? The solution is simple. We create a table of all the character who hit the wall and check if a character that hit the wall is already in the table.

local characters = {}

WallPart.Touched:Connect(function(hit)
	local character = hit.Parent
	local humanoid = character:FindFirstChildWhichIsA("Humanoid")
	if humanoid and character:IsA("Model") and not table.find(characters, character) then -- Detects if the hit part is part of a character character
		table.insert(characters, character)
		-- Other code
	end
end)

Step #2: Animation
For this step we want to create a ball that appears at the place of collision and then disappears. We want to use the characters torso position as the position of the hit. This way the ball is centered around the character. With the help of DebrisService we can make the Ball disappear.

local Debris = game:GetService("Debris")

local function CreateEffect(position : Vector3)
	local Ball = Instance.new("Part")
	Ball.Shape = Enum.PartType.Ball
	Ball.Color = Color3.new(0,1,1)
	Ball.Material = Enum.Material.Neon
	Ball.CanCollide = false
	Ball.Anchored = true
	Ball.Size = Vector3.new(5,5,5)
	Ball.Position = position
	Ball.Parent = workspace

	Debris:AddItem(Ball,0.15)
end

CreateEffect(character.Torso.Position or character.UpperTorso.Position)

Step #3: Anti-Gravity
To accomplish Anti-Gravity on an assembly is an easy operation. Parent a BodyForce to the assembly RootPart. Multiply the assemblies mass by the Workspace.Gravity to get the counteractive force. Setting the Y-Value of BodyForce.Force to the counteractive force will make the part achieve anti-gravity.

local function AntiGravity(assembly : BasePart)
	local GravityForce = Vector3.new(0, assembly.AssemblyMass * workspace.Gravity, 0)

	local BodyForce = Instance.new("BodyForce")
	BodyForce.Force = GravityForce
	BodyForce.Parent = assembly
end

AntiGravity(character:FindFirstChild("HumanoidRootPart"))

Step #4: Rag-Doll
This part is up to you. Ragdoll systems can be complicated because of the different rig types. Ragdoll the player, and also, if you want, kill them in this stage as well, after the joints have been set up. You’ll also want to make the players humanoid root part not able to collide.

Step #5: Fling
This part is easy. You simply get the relative position of the players using

local direction = WallPart.CFrame:PointToObjectSpace(character.HumanoidRootPart.Position)
character.HumanoidRootPart:ApplyImpulse(direction*100)
1 Like

https://youtu.be/tUEImJ4Vddw is the link

hm that’s interesting I’ll make something out of that

Use game:GetService(“TweenService”). Here’s a video on how to use it: Roblox TweenService Tutorial.

i know what tweenservice is but that’s not an answer

only the impulse doesn’t work that’s all but for the rest it’s fine, but the gravity thing also doesn’t make you go up unless you jump

Sorry about that. I looked over my code again, I it works for me. That leads me to believe that you aren’t ragdolling the character correctly, as you mentioned the anti-gravity only worked when you jumped. If you ragdolled the character however, then the player wouldn’t be able to jump. Make sure that you are disabling the motor6d’s after ragdolling the character and also setting the humanoid state to physics. This can be done using:

for _,child in ipairs(character:GetChildren()) do
	if child:IsA("Motor6D") then
		child.Enabled = false
	end
end

humanoid:ChangeState(Enum.HumanoidStateType.Physics)

If you do not know how to ragdoll the player however then not to worry! It is unfinished, but I am currently working on a universal character ragdoll script.

2 Likes

i don’t really know how to do the ragdoll yes lol but i tried it without ragdoll first but it didn’t work

Don’t worry. I’ve almost finished my simple ragdoll system. It was going to be really hard at first since I would have had to calculate everything manually. However, I discovered that Motor6D’s have a C0 and C1 property that gives you the CFrame offset of the joint. This has enabled it to work for custom character rigs as well! All I’m doing right now is messing around with the rotation limits of the BallSocketConstraint until I get the effect I want. I’ll release another post when I’ve finished.

1 Like

I’ve been messing around with ball socket constraints for a while now, I’m trying to make a tv on the wall which follows you around :sweat_smile:

Oh. Well, to make something like that you could use the CFrame.lookAt(Vector3 Orgin, Vector3 LookAt) command. The first argument is the origin position and the second the position you want to look at. So, for example you’d do:

TvPartExample.CFrame = CFrame.lookAt(TvPartExample.Position, CharacterHeadPartExample.Position)

Or, if you wanted to make it smoother, you could use TweenService.

local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(1)

-- in loop:
local Tween = TweenService:Create(TvPartExample,Info,{CFrame = CFrame.lookAt(TvPartExample.Position, CharacterHeadPartExample.Position)}):Play()
-- end loop

If the TV you are creating is a model with multiple parts then you can tween the primary part with all other parts welded to the primary part. I have included a tutorial link below.

1 Like

Alright, I’ve completely finished! I decided that instead of rewriting and explaining everything and the changes I made and why I’d instead give you a link to the model I created that does exactly what you want as well as allow for customization.

Something you should be aware of before using this though is that for the direction vector when flinging the player I used CFrame.LookVector. This means that the no matter where you touch the wall it will fling you in the direction the front face of the part has. To help you know which face is the front face I used a SurfaceSelection object to highlight it for you. Because I have no idea how experienced you truly are with scripting in Luau I know this can sound like gibberish to you. I will keep it brief. Do not remove the surface selection object because that will cause a :WaitForChild(“SurfaceSelection”) method I called in the code to wait forever and CAUSE THE SCRIPT TO NOT RUN/WORK. Only remove it if you also know what line to remove in the script. Also, there is no reason to remove it as it is destroyed whenever the game is run, so it’s only visible while editing in studio.

I recommend only having the surface that is highlighted exposed to the player and having the other surfaces unreachable. If the player touches the other surfaces it can lead to some seemingly weird results.

https://www.roblox.com/library/6586493953/Forcefield-Fling

2 Likes

Alrighty thanks! I’ll check this out and mess around with it!