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

Local script only functioning sometimes?

Asked by 7 years ago

The goal of this script is to tell when a player kills another player, and make a gui change accordingly. The problem is, it only functions sometimes, when the player first joins, and then randomly after that point. No errors. Local script inside of a gui

game:GetService('Players').LocalPlayer.CharacterAdded:connect(function(charModel)
    local Value1 = charModel:WaitForChild("SwordPart"):WaitForChild("Killed")
Value1.Changed:connect(function()
    local Sound = script:WaitForChild("indicator")
    local Frame = script.Parent.Frame
    local Plrname = script.Parent.Frame.PlrName
    Plrname.Text = Value1.Value
    Frame.Visible = true
    Sound:Play()
    wait(5)
    Frame.Visible = false
end)
end)

Script inside of a part

local Obj = script.Parent

Obj.Touched:connect(function(Hit)
    if Hit.Parent:findFirstChild("Humanoid") then
        Hit.Parent.Humanoid:TakeDamage(10)
        if Hit.Parent.Humanoid.Health == 0 then
            script.Parent.Killed.Value = Hit.Parent.Name
        end
    end
end)

0
Is the 'Obj' here a projectile? (e.g. Bullet) If so, I don't think there's something wrong with it. FoolInSpecs 35 — 7y
0
obj is a part that the player holds pluginfactory 463 — 7y

Answer this question