|
| 15 Sep 2015 11:58 PM |
I have this script that is supposed to work like the LinkedLeaderboard, but instead of changing values in the leaderboard, it changes values in a player's gui.
print("KillCorder Loaded!") DefaultCam=game.Workspace.CurrentCamera
function onHumanoidDied(humanoid, player) local stats = player:findFirstChild("PlayerGui") if stats ~= nil then local mons = stats:findFirstChild("MoneyGui") local deaths = mons.cashText.Points deaths.Value = deaths.Value - 0 game.Workspace.CurrentCamera=DefaultCam local killer = getKillerOfHumanoidIfStillInGame(humanoid)
handleKillCount(humanoid, player) end end
function onPlayerRespawn(property, player) if property == "Character" and player.Character ~= nil then local humanoid = player.Character.Humanoid local p = player local h = humanoid humanoid.Died:connect(function() onHumanoidDied(h, p) end ) end end
function getKillerOfHumanoidIfStillInGame(humanoid) -- returns the player object that killed this humanoid -- returns nil if the killer is no longer in the game local tag = humanoid:findFirstChild("creator")
-- find player with name on tag if tag ~= nil then local killer = tag.Value if killer.Parent ~= nil then -- killer still in game return killer end end
return nil end
function handleKillCount(humanoid, player) local killer = getKillerOfHumanoidIfStillInGame(humanoid) if killer ~= nil then local stats = killer:findFirstChild("PlayerGui") if stats ~= nil then local kills = stats:findFirstChild("MoneyGui") if killer ~= player then local pts = kills.cashText.Points.Value pts = pts + 1 else local pts = kills.cashText.Points.Value pts = pts - 1 end end end end
I get nothing out of the output box, or in the console in game when I kill my alt acc.
I think it has to do with location, but I'm not sure.
Please help me. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 12:00 AM |
I do realize now, after I posted, that the
" local deaths = mons.cashText.Points deaths.Value = deaths.Value - 0 "
part is redundant...
|
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 12:14 AM |
| leaderstats should be a child of the player, not the playergui |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 12:24 AM |
That is what I'm having trouble with, I don't want to change a value in the leaderstats, I want to change a value in the Player's Gui. This way, a script can update a Gui with the new value found in the Player's Gui.
--I can put my waits wherever I want. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 12:25 AM |
| Are you using the game's leaderboard OR a custom made GUI |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 12:28 AM |
A custom Gui.
--I can put my waits wherever I want. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 12:31 AM |
| Too lazy to read over, so if you want an easier check, if someone died, just check if their health is == 0. There's only one person who can gain points from killing unless there's a sheriff in your game, so you don't need to check who killed who, if u understand what I'm saying |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 12:37 AM |
*Facepalm can be heard around the world*
Everyone in my game is going to be killing everyone. Well, sort of. There will be teams, but that's not the point. I don't know what I'm doing wrong. I'll try putting 'print()' functions in to see where it's going wrong, but I'll have to do that later.
If you are going to comment, please read the whole post, or don't comment at all.
--I can put my waits wherever I want. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 12:38 AM |
I still want help, by the way.
--I can put my waits wherever I want. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 04:21 AM |
This is why kill/death handling shouldn't be handled by outdated methods (like 'tagging'), they're just inefficient, and some people mess up terribly.
Go learn RemoteEvents |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 08:51 PM |
@warpsyking
Thanks for the idea. It looks much easier.
--I can put my waits wherever I want. |
|
|
| Report Abuse |
|
|