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

Why won't this mesh rotate? and why does the instance spawn ABOVE the forcefield?

Asked by 8 years ago

I am creating a forcefield tool and i'm still tweaking all of the parts, but i'm stumped at a part. Whenever this mesh spawns, the object doesn't rotate continually like i want it to. Also, when the mesh spawns, it spawns above the Force Field instead of inside it, next to the humanoid like I want it too. I'm assuming that's a collision issue, but i still don't know how to fix it. Here is the code:

01local tool = script.Parent
02 
03local health = false
04 
05x = math.random(25, 50)
06y = math.random(25, 50)
07 
08a = 0
09 
10b = 0
11 
12local debounce = false
13 
14local character = game:GetService('Players').LocalPlayer
15local player = character.Character or character.CharacterAdded:wait()
View all 78 lines...

it's quite a lot of code, but it's just spawning two different parts next to your character and damages anyone else that touches it, lol. Thanks in advance!

0
I also now realize, looking at my code as a whole that at the end, the until statement also contains the explosion.position so it's repeating until it's at the position, so i tried putting an end statement at the end of the until, but that still doesn't work :/ Sparkflyer34 40 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

When you set a part's position, it will not allow the part to clip through other parts, so it will automatically move it upwards and reset the rotation until it's not clipping any other parts.

The way to get around this would be to use CFrame

You will need to do something along these lines:

1Part.CFrame = CFrame.new(
2    XPosition,
3    YPosition,
4    ZPosition
5) *CFrame.Angles(
6    math.rad(XRotation),
7    math.rad(YRotation),
8    math.rad(ZRotation)
9)

Here is an article on CFraming if you wish to read up on it more.

Hope this helps!

Ad

Answer this question