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

Humanoid.Died and Humanoid.HealthChanged not working with FE?

Asked by
lomo0987 250 Moderation Voter
8 years ago

The scripts are inside a model while that model is inside Workspace. I don't think it's the location but rather how it's getting fired.

I'm trying to use Humanoid.Died:connect() along with Humanoid.HealthChanged:connect() but they seem to not want to work?

I looked at the wiki but it doesn't say anything about this.

Edit -----------------------------------------

Script 1

local cash = script.Parent.Config.Cash.Value
local xp = script.Parent.Config.Exp.Value
local Humanoid = script.Parent.NPCoid

function Died() 
    local tag = Humanoid:findFirstChild("creator") 
    if tag ~= nil then 
        if tag.Value ~= nil then 
            local find = tag.Value:findFirstChild("InParty")
            local Leaderstats = tag.Value:findFirstChild("Stats") 
            if Leaderstats ~= nil then
                local player = tag.Value
                if player ~= nil then
                    if player.InParty.Value == "" then
                        print("Alone!")
                        local Bonus = Leaderstats.Bonus
                        Leaderstats.XP.Value = math.floor((Leaderstats.XP.Value + (cash*(Bonus.Value/100))))
                        Leaderstats.Gold.Value = math.floor((Leaderstats.Gold.Value + (cash*(Bonus.Value/100))))
                        if player:findFirstChild("Quests").Quest1 ~= nil then
                            player.Quests.Quest1.Total_Kills.Value = player.Quests.Quest1.Total_Kills.Value + 1
                        end
                        wait(0.1)
                        script:Destroy()
                    else
                        print("InParty!")
                        local party = game.Lighting.Party:findFirstChild(player.InParty.Value)
                        local RewardParty = party:GetChildren()
                        for i = 1, #RewardParty do
                            local PartyMember = game.Players:findFirstChild(RewardParty[i].Name)
                            print(PartyMember)
                            if PartyMember:findFirstChild("Quests").Quest1 ~= nil then
                                PartyMember.Quests.Quest1.Total_Kills.Value = PartyMember.Quests.Quest1.Total_Kills.Value + 1
                            end
                            local leaderstat = PartyMember:findFirstChild("Stats")
                            print(leaderstat.Parent)
                            local Bonus = leaderstat.Bonus
                            leaderstat.XP.Value = math.floor((leaderstat.XP.Value + ((cash*(Bonus.Value/100)/#RewardParty))))
                            leaderstat.Gold.Value = math.floor((leaderstat.Gold.Value + ((cash*(Bonus.Value/100)/#RewardParty))))
                            script:Destroy()
                        end
                    end
                end
            end 
        end 
    end 
end 
Humanoid.Died:connect(Died) 

Script2

robo = script.Parent:clone()
NP = script.Parent.NPCoid
health = script.Parent.NPCoid.Health
mhealth = script.Parent.NPCoid.MaxHealth
name = script.Parent
lvl = script.Parent.Config.Level.Value
name.Name = "Level: "..lvl.." NPC - "..health.."/"..mhealth

NP.HealthChanged:connect(function (health)
    name.Name = "Level: "..lvl.." NPC - "..health.."/"..mhealth
    local x = script.Parent
    if x ~= nil then
        if script.Parent.NPCoid.Health < 1 then
            local robot = robo:clone()
            robot.Parent=script.Parent.Parent
            robot:makeJoints()
            robot.NPCoid.Health = robot.NPCoid.MaxHealth
            wait(0.01)
            script.Parent:remove()
        end
    end
end)    
0
What exactly is going on? Are you getting any errors? What exactly are you trying to do? Please explain more, you gave barely any information TurboFusion 1821 — 8y
0
No errors, nothing. Here, let me do an edit and show you the 2 scripts that aren't working the thing is though, nothing happens at all.. lomo0987 250 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Even with FilteringEnabled, things like the player's character are fully controlled by the client (unless you specifically set the player's model to be owned by the server - but this would probably disable animation, and probably movement too). Thus, these events could very well be just be staying on the client. You'll have to listen for the events using a LocalScript and then, via a RemoteEvent, send the data to the server.

Ad

Answer this question