crate109Join Date: 2010-11-24 Post Count: 315 |
It breaks at the line 9, it should get information from the player I am targeting. I am trying to reach the Players.player from the Character in workspace I am targeting. What is the problem?
MOS=game.Players.LocalPlayer:GetMouse()
while wait() do
if MOS.Target then
if MOS.Target.Name ~=("Tool") and MOS.Target.Name ~=("Hat") and MOS.Target.Name ~=("Sabre") then
if MOS.Target.Parent:FindFirstChild("Humanoid") or MOS.Target.Parent.Parent:FindFirstChild("Humanoid") and MOS.Target.Parent.className~=("Tool") and MOS.Target.Parent.className~=("Hat") then
script.Parent.InfoGuiverGUI.InfoGiver.Visible = true
script.Parent.InfoGuiverGUI.InfoGiver.PlayerName.Text = "Player: " .. MOS.Target.Parent.Name
if game.Players:GetPlayerFromCharacter(game.Workspace.Player):IsInGroup("883491") then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "Insigna: " .. game.Players:GetPlayerFromCharacter(game.Workspace.Player):GetRoleInGroup("883491")
else
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "This is not a US soldier!"
end
if MOS.Target.Parent.Humanoid.Health 0 then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerHealth.Text = "Status: Wounded"
elseif MOS.Target.Parent.Humanoid.Health <= 0 then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerHealth.Text = "Status: Dead"
else script.Parent.InfoGuiverGUI.InfoGiver.PlayerHealth.Text = "Status: Healthy"
end
else
script.Parent.InfoGuiverGUI.InfoGiver.Visible = false
end
end
end |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
Could you mark the line that is causing the problem? |
|
crate109Join Date: 2010-11-24 Post Count: 315 |
if game.Players:GetPlayerFromCharacter(game.Workspace.Player):IsInGroup("883491") then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "Insigna: " .. game.Players:GetPlayerFromCharacter(game.Workspace.Player):GetRoleInGroup("883491")
else
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "This is not a US soldier!"
end
Everything else works, I tried. I just don't know how to get Player information from my Target (Character, the Workspace player) |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
What exactly is this script in? In a tool, hopperbin, block, ...? |
|
crate109Join Date: 2010-11-24 Post Count: 315 |
It is a LocalScript (alone) in the StarterGui. There is another GUI in the StarterGui.
Here is the script: When you put your mouse on a player, in a game (when you hover a player) a GUI pop on your screen (the GUI in the starterGUI). Inside this GUI, you can have the name of the player hover. When you stop hovering the player, the GUI goes back invisible.
This part of the script breaks everything:
-----------------------
if game.Players:GetPlayerFromCharacter(game.Workspace.Player):IsInGroup("883491") then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "Insigna: " .. game.Players:GetPlayerFromCharacter(game.Workspace.Player):GetRoleInGroup("883491")
else
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "This is not a US soldier!"
end
-----------------------
I think I'm not using the GetPlayerFromCharacter() thing correctly. |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
If it's in StarterGui, then it will be put into every player's PlayerGui when they join. Instead of using GetPlayerFromCharacter(), try just using game.Players.LocalPlayer |
|
crate109Join Date: 2010-11-24 Post Count: 315 |
Alright ok I will try this and tell you if it works !! :P |
|
crate109Join Date: 2010-11-24 Post Count: 315 |
Ohhhh yes it works :DDD
Thank you so much! You can't imagine how hard I worked on that script and it is because of you if I completed it :DD
Once again, thank you !!
Crate109. |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
No problem lol |
|
crate109Join Date: 2010-11-24 Post Count: 315 |
Err... Actually it seems to be working on Edit mode, but when I get on the field with my group members, it doesn't work....
Doesn't work online :/ |
|
crate109Join Date: 2010-11-24 Post Count: 315 |
The problem is, when we put our mouse on someone, we get our own rank lol! |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
Oh I see now. Sorry, I misunderstood what you were asking before. Try this:
if game.Players:FindFirstChild(game.Workspace.Player.Name) then
if game.Players[game.Workspace.Player.Name]:IsInGroup("883491") then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "Insigna: " .. game.Players[game.Workspace.Player.Name]:GetRoleInGroup("883491")
else
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "This is not a US soldier!"
end
end |
|
crate109Join Date: 2010-11-24 Post Count: 315 |
Still not working :/ |
|
crate109Join Date: 2010-11-24 Post Count: 315 |
Here is the whole script (A LocalScript in the StarterGUI):
MOS=game.Players.LocalPlayer:GetMouse()
while wait() do
if MOS.Target then
if MOS.Target.Name ~=("Tool") and MOS.Target.Name ~=("Hat") and MOS.Target.Name ~=("Sabre") then
if MOS.Target.Parent:FindFirstChild("Humanoid") or MOS.Target.Parent.Parent:FindFirstChild("Humanoid") and MOS.Target.Parent.className~=("Tool") and MOS.Target.Parent.className~=("Hat") then
script.Parent.InfoGuiverGUI.InfoGiver.Visible = true
script.Parent.InfoGuiverGUI.InfoGiver.PlayerName.Text = "Player: " .. MOS.Target.Parent.Name
if game.Players:FindFirstChild(game.Workspace.Player.Name) then
if game.Players[game.Workspace.Player.Name]:IsInGroup("883491") then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "Insigna: " .. game.Players[game.Workspace.Player.Name]:GetRoleInGroup("883491")
else
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "This is not a US soldier!"
end
end
if MOS.Target.Parent.Humanoid.Health 0 then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerHealth.Text = "Status: Wounded"
elseif MOS.Target.Parent.Humanoid.Health <= 0 then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerHealth.Text = "Status: Dead"
else script.Parent.InfoGuiverGUI.InfoGiver.PlayerHealth.Text = "Status: Healthy"
end
else
script.Parent.InfoGuiverGUI.InfoGiver.Visible = false
end
end
end
end |
|
wish_zJoin Date: 2009-02-11 Post Count: 15392 |
The script loads before the player. Try adding a wait(2) at top |
|
crate109Join Date: 2010-11-24 Post Count: 315 |
I added wait(3).. still not :/
I don't think that's the prob.
Also, when I put my cursor on someone, the GUI does not disappear, as it should do. And no Insigna show up. |
|
crate109Join Date: 2010-11-24 Post Count: 315 |
This whole script works, but just in Solo mode. Won't run correctly Online:
wait(3)
MOS=game.Players.LocalPlayer:GetMouse()
while wait() do
if MOS.Target then
if MOS.Target.Name ~=("Tool") and MOS.Target.Name ~=("Hat") and MOS.Target.Name ~=("Sabre") then
if MOS.Target.Parent:FindFirstChild("Humanoid") or MOS.Target.Parent.Parent:FindFirstChild("Humanoid") and MOS.Target.Parent.className~=("Tool") and MOS.Target.Parent.className~=("Hat") then
script.Parent.InfoGuiverGUI.InfoGiver.Visible = true
script.Parent.InfoGuiverGUI.InfoGiver.PlayerName.Text = "Player: " .. MOS.Target.Parent.Name
if game.Players.LocalPlayer:IsInGroup("883491") then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "Insigna: " .. game.Players.LocalPlayer:GetRoleInGroup("883491")
else
script.Parent.InfoGuiverGUI.InfoGiver.PlayerRank.Text = "This is not a US soldier!"
end
if MOS.Target.Parent.Humanoid.Health 0 then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerHealth.Text = "Status: Wounded"
elseif MOS.Target.Parent.Humanoid.Health <= 0 then
script.Parent.InfoGuiverGUI.InfoGiver.PlayerHealth.Text = "Status: Dead"
else script.Parent.InfoGuiverGUI.InfoGiver.PlayerHealth.Text = "Status: Healthy"
end
else
script.Parent.InfoGuiverGUI.InfoGiver.Visible = false
end
end
end
end |
|
crate109Join Date: 2010-11-24 Post Count: 315 |
I was told that LocalScript do not work correctly Online, any idea of how I could convert my LocalScript into a Script?
|
|