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

How to make a player "flattened?"

Asked by 7 years ago

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.

0
You can always make an invisible part with the players decal on it so it looks flattened. greatneil80 2647 — 7y
0
I will be back with a sound solution in a little while. I've been working on it for an hour now. Just a bit more work and it will be done and pretty good if you ask me. I can show you it through a gif later. KingLoneCat 2642 — 7y
0
But, my solution will only work with R15 players, I haven't thought about R6 yet. KingLoneCat 2642 — 7y

3 answers

Log in to vote
2
Answered by 7 years ago
Edited 7 years ago

Hi tygerrupercut3,

I've been working on this flattened thing for the past hour trying to work the numbers right and get the coordinates right. So, I finally came to a good-enough solution. I mean.... a pretty good solution if you ask me, considering how easy it is. Well, I basically make use of the values inside of the Humanoid called: BodyHeightScale and HeadScale so that I can resize their avatars with ease. Then when I rescale them to a flat character, I make the head point up so that it looks like the character has been flattened.

After this, I anchor all of the parts and remove all the accessories that the character has. Well, I make the accessories transparent so that I can restore them with ease. Anyway, that's how I did it, let's just get into the script. Just know that this script isn't accustomed to your game, it's just something I made to show you a way you can accomplish your task.

Local Script inside StarterGui

01local uis = game:GetService("UserInputService"); -- UserInputService for key input detection and stuff.
02local players = game:GetService("Players");
03local player = players.LocalPlayer;
04local 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 
06uis.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 
View all 52 lines...

Well, this is the basic gist of it. You can find this in use here.

I hope I helped and have a wonderful day/night.

Thanks,

Best regards,

~~ KingLoneCat

0
The script isn't that big. Just lots of comments. KingLoneCat 2642 — 7y
0
Necrobump, beautiful code, accepted answer for you since tyger said it worked greatneil80 2647 — 4y
Ad
Log in to vote
0
Answered by
zyrun 168
7 years ago
Edited 7 years ago

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
02function 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
11end
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 
15local CharRootPart = Plr.Character.HumanoidRootPart -- The HumanoidRootPart of the character
View all 23 lines...

Hope this helped! - Zyrun

0
There is always a way! When there's a will, there's a way. KingLoneCat 2642 — 7y
Log in to vote
0
Answered by 7 years ago

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.

Answer this question