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

Why aren't my blocks sticking to my body?

Asked by 10 years ago

Here's my code.

01local enabled = true
02Player = script.Parent.Parent
03mouse = Player:GetMouse()
04run = game:GetService("RunService")
05local Left_Arm = script.Parent:FindFirstChild("Left Arm")
06local Right_Arm = script.Parent:FindFirstChild("Right Arm")
07local Core = script.Parent:FindFirstChild("Torso")
08local Left_Leg = script.Parent:FindFirstChild("Left Leg")
09local Right_Leg = script.Parent:FindFirstChild("Right Leg")
10function onKeyDown(key)
11    key = key:lower()
12    if key == "t" then
13        game:GetService("Chat"):Chat(Player.Character.Head, "Focus the mind, reflect upon yourself, and determine the goal.")
14        Left_Arm = Instance.new ("Part")
15        Right_Arm = Instance.new("Part")
View all 87 lines...

The blocks won't obey the code which god created....LUA.

0
Do the parts actually spawn but not stick? (Welds may not work) or do the Parts not spawn? Look in the Output, and I believe workspace on line 50 and 58 should have a capital W Mystdar 352 — 10y
0
They spawn and just don't stick. kingalpha1 15 — 10y

1 answer

Log in to vote
0
Answered by
Discern 1007 Moderation Voter
10 years ago

Now I'm terrible with Welds, but I'm pretty sure I have the correct solution.

This is happening multiple times in the script, but let's just take lines 59-63 as an example.

You setting the script's parent last. If you look at line 62, you're trying to access "script.Parent". The problem is, you have not set the parent at that time (You do in Line 63). Basically, you're trying to access its parent that doesn't exist. You need to set the script's parent before you try to access its parent.

You probably already know this, but Instance.new() has another argument. The first one is deciding what you are inserting, the second argument sets its parent. So really you can merge the creation line and parental assigning line into 1 function. Here is the fixed script:

01local enabled = true
02Player = script.Parent.Parent
03mouse = Player:GetMouse()
04run = game:GetService("RunService")
05local Left_Arm = script.Parent:FindFirstChild("Left Arm")
06local Right_Arm = script.Parent:FindFirstChild("Right Arm")
07local Core = script.Parent:FindFirstChild("Torso")
08local Left_Leg = script.Parent:FindFirstChild("Left Leg")
09local Right_Leg = script.Parent:FindFirstChild("Right Leg")
10function onKeyDown(key)
11    key = key:lower()
12    if key == "t" then
13        game:GetService("Chat"):Chat(Player.Character.Head, "Focus the mind, reflect upon yourself, and determine the goal.")
14        Left_Arm = Instance.new ("Part")
15        Right_Arm = Instance.new("Part")
View all 82 lines...

Hope I helped. :)

Ad

Answer this question