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

ServerScriptService.Punch Server:3: Expected identifier, got '('?

Asked by 2 years ago
Edited 2 years ago
game.ReplicatedStorage.Remotes.Punch.OnServerEvent:Connect(function(player,damage)
    for i,target in pairs(game.Workspace:GetDescendants()) do
        if target.("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)

I don't know the problem on line 3 its so annoying :/

0
Help me lol tanQer8 2 — 2y

2 answers

Log in to vote
0
Answered by
NEILASc 84
2 years ago
Edited 2 years ago
  1. :GetDescendats() Gets Everything Including Model Names. So use :GetChildren()
  2. target.("Humanoid") does not need that infact it needs target:FindFirstChild("Humanoid") 2.5. ("Humanoid") is not required but you could use ["name here"] if it has any special characters.

tip: tip 2.5 doesnt work on everything so if you have a object called "dh h8" you do not need to code it like parent:FindFirstChild("["dh h8"]") you need to code it like parent:FindFirstChild("dh h8") or parent:FindFirstChild([["dh h8"]]) -- anything inside the double brackets count as a string

your modifyed code would look like:

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)

0
Ok new problem lol is says tanQer8 2 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
if target:IsA("Humanoid") and
0
Thx :) tanQer8 2 — 2y

Answer this question