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

[SOLVED] Why do the parts I clone always go on top of everything else when they appear?

Asked by 6 years ago
Edited 6 years ago

If you've ever seen My Hero Academia, an anime show, I'm trying to make a Todoroki Ice Slide move, I'm not entirely done with it yet, but everything but one thing that I've done so far works. This script makes clones of a part inside of the script, and puts them behind the player to look like the player is using ice to push him/herself forward. It creates the parts, but every part it clones, automatically gets put on top of everything else and it makes it look weird.

01UIS.InputBegan:connect(function(key)
02    if key.KeyCode == iceSlideKey and enabled == true then
03        keyDown = true
04        while keyDown == true do
05            char.Humanoid.Jump = true
06            char.HumanoidRootPart.Velocity = char.HumanoidRootPart.CFrame.lookVector*100
07            local slide = iceSlide:Clone()
08            slide.Position = char.HumanoidRootPart.Position - char.HumanoidRootPart.CFrame.lookVector*10 - Vector3.new(0,10,0)
09            slide.Parent = game.Workspace
10            slide.Anchored = true
11            slide.Orientation = char.HumanoidRootPart.Orientation + Vector3.new(0,180,0)
12            slide.CanCollide = false
13            wait(0.1)
14        end
15    end
View all 22 lines...

By the way, this isn't the full script, so if you test it, it won't work. Here's a gif of what it does. https://gyazo.com/a7bc1d36316ab3e7009a7421e02163ea

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
6 years ago

Instead of using the Position, use the CFrame to avoid this from happening. The way ROBLOX positioning works is by respecting collisions. Using CFrame basically set and stones the position.

0
mk ill try it Knineteen19 307 — 6y
0
I changed the set position line from position to cframe, but nothing changed, is there a way I'm supposed to use cframe to do orientation? Knineteen19 307 — 6y
0
Also it worked as intended before i put the orientation part in, and only started messing up when i put it in Knineteen19 307 — 6y
0
Actually, I just noticed, when I remove the orientation part, it still rotates it thanks to the cframe, but it's backwards... Knineteen19 307 — 6y
View all comments (4 more)
0
Thanks though! Knineteen19 307 — 6y
0
o-okay. Glad you got it..? Shawnyg 4330 — 6y
0
yeah it fixed my problem, i just had to rotate the mesh around lol Knineteen19 307 — 6y
0
Alright good Shawnyg 4330 — 6y
Ad

Answer this question