So I have this hammer weapon (a giant hammer thing) and when the user smashes another player, I want them to look flattened on the ground for a few seconds (they look like flat Stanley on the ground). I already have an animation that makes the victim lay on the ground, but any help on making a character appear flat/thin would be much appreciated.
Hi tygerrupercut3,
01 | local uis = game:GetService( "UserInputService" ); -- UserInputService for key input detection and stuff. |
02 | local players = game:GetService( "Players" ); |
03 | local player = players.LocalPlayer; |
04 | local flattened = false ; -- I use this as a way to decide if the character needs to be flat or come back to normal size. Once the character clicks, this sets to a certain value and I have the function check for that value and if it's that value, that means the character's flat and needs to come back to normal size, so I do that. |
05 |
06 | uis.InputBegan:Connect( function (key, gp) |
07 | if key.KeyCode = = Enum.KeyCode.Q and not gp then |
08 | local char = player.Character or player.CharacterAdded:Wait(); |
09 | local hum = char:WaitForChild( "Humanoid" ); |
10 | local head = char:WaitForChild( "Head" ); |
11 | local neck = head:WaitForChild( "Neck" ); -- The Motor6D, I need this to make the head point up. |
12 | local height = hum:WaitForChild( "BodyHeightScale" ); |
13 | local torso = char:FindFirstChild( "HumanoidRootPart" ); |
14 | local anchoring = false -- I use this to decide if the parts should be anchored or not. They need to be anchored when the character gets flattened otherwise, they need to be unanchored. The reason I anchor them is to avoid the glitches with the physics in the game. |
15 |
Thanks,
Best regards,
~~ KingLoneCat
This may not be the answer you're looking for, but I don't think there is a way... In your case, I would use One of Two ways:
1) Make a model of the flattened character, but not actually flatten them. Make parts and customize them with the player's colors and whatnot. Be sure to make the actual player's model invisible.
2) Anchor the character and CFrame them through the ground face up/down. This would look something like this:
01 | -- In a sever script |
02 | function AnchorAllParts(InputArea) -- Will make sure anything that can be anchored will be anchored |
03 | for _, V in pairs (InputArea:GetChildren()) do |
04 | if V:IsA( "BasePart" ) or V:IsA( "UnionOperation" ) or V:IsA( "MeshPart" ) then |
05 | V.Anchored = true |
06 | end |
07 | if #V:GetChildren() > 0 then |
08 | AnchorAllParts(V) |
09 | end |
10 | end |
11 | end |
12 |
13 | -- Do your smashy stuff In this area here. Make sure you get the Player's Character HuamnoidRootPart as a varible so we can CFrame it |
14 |
15 | local CharRootPart = Plr.Character.HumanoidRootPart -- The HumanoidRootPart of the character |
Hope this helped! - Zyrun
I tried your script, and got it to work with a little tweaking to my needs. Thank you for taking time to make a nice script like that.