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

Character is not a valid member of Model "Workspace.tanQer8"?

Asked by 2 years ago
game.ReplicatedStorage.Remotes.Punch.OnServerEvent:Connect(function(player,damage)
            for i,target in pairs(game.Workspace:GetChildren()) do
                    if target:FindFirstChild("Humanoid") and target.Parent.Name ~= player.Name then
                            if (target.Character.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude <5 then
                                    target.character.Humanoid.Health -= damage
                                end
                        end
                end
        end)

This i accually dont under stand why line 4 isn't working. here is the full error:

Character is not a valid member of Model "Workspace.tanQer8" - Server - Punch Server:4 Stack Begin - Studio Script 'ServerScriptService.Punch Server', Line 4 - Studio - Punch Server:4 Stack End - Studio

2 answers

Log in to vote
0
Answered by 2 years ago

Hey,

Try to define character as 'local Character = Player.Character or Player.CharactedAdded:Wait()'

Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Hey! I am not entirely sure if I know what you mean, but Character is only a property of game.Players.tanQer8, not Workspace.tanQer8.

Answer this question