Why won't this mesh rotate? and why does the instance spawn ABOVE the forcefield?
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:
01 | local tool = script.Parent |
05 | x = math.random( 25 , 50 ) |
06 | y = math.random( 25 , 50 ) |
14 | local character = game:GetService( 'Players' ).LocalPlayer |
15 | local player = character.Character or character.CharacterAdded:wait() |
17 | tool.Equipped:connect( function (mouse) |
18 | mouse.KeyDown:connect( function (key) |
19 | if key = = "q" and debounce = = false then |
22 | local ForceField = Instance.new( "Part" , player) |
23 | ForceField.BrickColor = BrickColor.new( "Deep blue" ) |
24 | ForceField.Transparency = 0.7 |
25 | ForceField.CanCollide = false |
26 | ForceField.Anchored = true |
27 | ForceField.Shape = Enum.PartType.Ball |
28 | ForceField.Size = Vector 3. new( 25 , 25 , 25 ) |
29 | ForceField.BottomSurface = Enum.SurfaceType.Smooth |
30 | ForceField.TopSurface = Enum.SurfaceType.Smooth |
31 | ForceField.Position = player.Torso.Position |
32 | ForceField.Parent = game.Workspace |
34 | ForceField.Touched:connect( function (hit) |
35 | local humanoid = hit.Parent:findFirstChild( "Humanoid" ) |
36 | if not hit:IsDescendantOf(player) and health = = false then |
38 | humanoid.Health = humanoid.Health - 3 |
39 | print ( "DEATH TO THE HEATHENS" ) |
45 | tool.Equipped:connect( function (mouse) |
46 | mouse.KeyDown:connect( function (key) |
47 | if key = = "q" and debounce = = false then |
48 | local explosion = Instance.new( "Part" , player) |
49 | local m = Instance.new( "SpecialMesh" ) |
51 | m.MeshType = "FileMesh" |
54 | m.Scale = Vector 3. new( 8 , 8 , 8 ) |
55 | explosion.Size = Vector 3. new( 8 , 8 , 8 ) |
56 | explosion.Anchored = true |
57 | explosion.CanCollide = false |
58 | explosion.Transparency = 0 |
60 | explosion.Rotation = Vector 3. new( 0 ,a, 0 ) |
65 | explosion.Position = player.Torso.Position |
66 | explosion.Parent = game.Workspace |
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!