Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

"RightArm" is not a valid member of model. I need some help please?

So this script is cloned inside of a part created and moved with another script inside of a tool. So basically what the script is trying to do is when it hits an object with a humanoid, it checks to see if the name is not equal to the casters name and d(debounce) is true(supposed to be false but I put true) . It then deletes the body velocity moving the part then, this is where it messes up. Torso gets Anchored, but RightArm does not. It gave me the error "right arm is not a valid member of model". So i tried to make RightArm = "Right Arm", as it is named Right Arm instead of RightArm in the Dummy(model). But it still does not work. Excuse my ignorance and my bad indentation as I am new to scripting, any help is appreciated and I realize I am probably just an idiot missing something small.

local player = script.Parent.Name
local d = true
local RightArm = "Right Arm"
local LeftArm = "Left Arm"
local RightLeg = "Right Leg"
local LeftLeg = "Left Leg"

	local function onT(p)
		if p.Parent:FindFirstChild("Humanoid") ~= nil and p.Parent.Name ~= player.Name and d == true then
			d = false
			script.Parent.BodyVelocity:Destroy()
			p.Parent.Torso.Anchored = true
			p.Parent.Head.Anchored = true
			p.Parent.RightArm.Anchored = true
			p.Parent.LeftArm.Anchored = true
			p.Parent.RightLeg.Anchored = true
			p.Parent.LeftLeg.Anchored = true
			p.Parent.Head.Anchored = true
			script.Parent.Anchored = true
			script.Parent.CFrame = p.Parent.Torso.CFrame
		local w = Instance.new("Weld")
			w.Part0 = script.Parent
			w.Part1 = p.Parent
			w.C0 = CFrame.new(0, 0, 0)
				for i = 1, 10 do
					p.Parent.Torso.CFrame = p.Parent.Torso.CFrame + CFrame.new(0, i*2, 0)
					script.parent.Size = script.Parent.Size + Vector3.new(i*1.5, i*1.5, i*1.5)
				end
		end
	end

	script.Parent.Touched:connect(onT)	

1 comment

0

In addition to what yoshi8080 said, you can also do local var = "Right Arm" local arm = game.Workspace.Player1[var] (but for these cases, the way yoshi8080 shows is better).

1 answer

✓ Accepted answer

Here are some minor mistakes found

  1. You don't need any variables for Right Arm and stuff here's an example of the right way to do it i.e,game.Workspace.Player1['Right Arm'] Another thing, which is optional and up to you to use or not, is changing function ToP(p) to script.Parent.Touched:connect(function(p)
local player = script.Parent.Name
local d = true

    script.Parent.Touched:connect(function(p)
        if p.Parent:FindFirstChild("Humanoid") ~= nil and p.Parent.Name ~= player.Name and d == true then
            d = false
            script.Parent.BodyVelocity:Destroy()
            p.Parent.Torso.Anchored = true
            p.Parent.Head.Anchored = true
            p.Parent['Right Arm'].Anchored = true
            p.Parent['Left Arm'].Anchored = true
            p.Parent['Right Leg'].Anchored = true
            p.Parent['Left Leg'].Anchored = true
            p.Parent.Head.Anchored = true
            script.Parent.Anchored = true
            script.Parent.CFrame = p.Parent.Torso.CFrame
        local w = Instance.new("Weld")
            w.Part0 = script.Parent
            w.Part1 = p.Parent
            w.C0 = CFrame.new(0, 0, 0)
                for i = 1, 10 do
                    p.Parent.Torso.CFrame = p.Parent.Torso.CFrame + CFrame.new(0, i*2, 0)
                    script.parent.Size = script.Parent.Size + Vector3.new(i*1.5, i*1.5, i*1.5)
                end
        end
    end
end)

2 comments

0

Thank you for the help, I greatly appreciate it!

0

your welcome

This discussion is preserved as it was. New answers, comments, and votes are closed.