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

Why it always says that the "RightLeg" is not valid member of a Model? TYIA

math.randomseed(tick())

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punchEvent = Instance.new("RemoteEvent", ReplicatedStorage)
punchEvent.Name = "PunchEvent"

local animations = {01741614100,01741629151,1741813502}

local function onPunchFired(plr)
	local char = game.Workspace:FindFirstChild(plr.Name)
	local humanoid = char.Humanoid
	local animation = Instance.new("Animation")
	local picked = math.random(1, #animations)
	animation.AnimationId = "http://roblox.com/asset/?id="..animations[picked]
	local animTrack = humanoid:LoadAnimation(animation)
	animTrack:Play()
	local dmgScript = script.DmgScript:Clone()
	if picked == 1 then
		dmgScript.Parent = char.RightHand
	elseif picked == 2 then
		dmgScript.Parent = char.LeftHand
	elseif picked == 3 then
		dmgScript.Parent = char.RightLeg
	end
	dmgScript.Disabled = false
	wait(0.4)
	dmgScript:Destroy()
end

punchEvent.OnServerEvent:Connect(onPunchFired)


2 answers

✓ Accepted answer

In an R15 rig, RightLeg is not a thing.

Consider changing it to RightUpperLeg or RightLowerLeg

1 comment

0

Thanks bro. It Works

If you want it to work with R6, then you need to do the following:

char["Right Leg"]

to access the right leg. This is how you access objects with spaces in their names. It doesn't always have to be the right leg to use that. You could also do:

workspace["Ob ject"]

Even if the name of the object doesn't have spaces, you can still use this method. Another method is to use FindFirstChild():

workspace:FindFirstChild('Ob ject').BrickColor = BrickColor.Red()

Hope this helped!

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