So I am trying to make a punch script I have one in serverscriptserver and anther in something else.. The error im geting is: RightHand is not a valid member of Model. My code is:
math.randomseed(tick()) local ReplicatedStorage = game:GetService("ReplicatedStorage") local punchEvent = Instance.new("RemoteEvent", ReplicatedStorage) punchEvent.Name = "PunchEvent" local animations = {1594228609} --Custom Animations Here Or To Add Animation make {Your Id Here, Your Id Here} 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 end dmgScript.Disabled = false wait(0.4) dmgScript:Destroy() end punchEvent.OnServerEvent:Connect(onPunchFired) ---------------
If you know how to fix it please reply, thanks.
Maybe you should replace line 9 with this..
local char = game.Players.LocalPlayer.Character
Hi, I don't know if you found the solution already or not but I was previously having the same problem. This stems from the event being called before the Character is loaded.
Solution:
local player = game.Players.LocalPlayer repeat wait() until player.Character local char = player.Character