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

Why does this script get all players who have "Arm1 in their character?

Asked by
Kegani 31
6 years ago
Edited 6 years ago

Hello

I'm going to take an extract of my script to show you what I mean.

function onClick(noot)
    local val = script.Parent.Parent.TextBox.Value.Value
    local text = script.Parent.Parent.TextBox
    val = text.Text
    local plr = game.Players:FindFirstChild(val)
    if plr and plr.Character and plr.Character:FindFirstChild("Arm1") then
        local hum = plr.Character.Humanoid
        local sta = script.Parent.Parent.Parent.status2
        script.Parent.Parent.Parent.status.Visible = false
        sta.Visible = true
        sta.user.Text = plr.Name
        hum.HealthChanged:Connect(function(Eealth)
            sta.health.Text = Eealth
            if Eealth == 100 then
                sta.healcolor.TextColor3 = Color3.fromRGB(16, 245, 4)
                sta.healcolor.Text = 'Health'
            end
            if Eealth <= 50 then
                sta.healcolor.TextColor3 = Color3.fromRGB(245,230,15)
            end
            if Eealth <= 25 then
                sta.healcolor.TextColor3 = Color3.fromRGB(255,93,3)
            end
            if Eealth == 0 then
                sta.healcolor.Text = 'Dead'
                sta.healcolor.TextColor3 = Color3.fromRGB(255,0,0)
            end
        end)
        sta.health.Text = plr.Character.Humanoid.Health
end

So this is supposed to put "Health" in a TextLabel, and change the color when the health is below 50 etc. Let's take as example

2 players, 1 just died, and it shows "Dead" in red. I go to the other player in the GUI, and in the stats it shows me his health but it's still at "Dead".

Another example this time with an explosion.

        local function onNoot()
            local e = Instance.new("Explosion")
            local ab = plr.Character.HumanoidRootPart.Position
            e.BlastRadius = 4
            e.Position = Vector3.new(ab.x, ab.y, ab.z)
            e.Parent = plr.Character.Arm1.red
        end
        sta.explode.MouseButton1Click:connect(onNoot)

Again, I press a button and the player who has the model named Arm1 in his character explodes. However, I noticed that when multiple players have the tracker, all of them explode when I only want one specific player to explode.

Please help me.

0
I'm a little unsure as to what you're asking, but assuming you want to blow up a player whose name you've entered in a text field, you could simply look for that character in the workspace by using workspace[playerName] Vexture 179 — 6y
0
Well, basically I only wanted to choose 1 specific player I typed the name in a GUI, but it exploded all players who had "Arm1" in their character. However, using workspace worked. Thanks! Kegani 31 — 6y

Answer this question