generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Problem getting information from a player in Workspace

Previous Thread :: Next Thread 
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
10 Jul 2014 10:07 AM
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 <= 50 and 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
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
10 Jul 2014 10:54 AM
Could you mark the line that is causing the problem?
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
10 Jul 2014 12:44 PM
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)
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
10 Jul 2014 02:08 PM
What exactly is this script in? In a tool, hopperbin, block, ...?
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
10 Jul 2014 06:28 PM
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.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
10 Jul 2014 06:42 PM
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
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
10 Jul 2014 07:34 PM
Alright ok I will try this and tell you if it works !! :P
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
10 Jul 2014 07:37 PM
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.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
10 Jul 2014 07:44 PM
No problem lol
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
11 Jul 2014 08:48 AM
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 :/
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
11 Jul 2014 09:08 AM
The problem is, when we put our mouse on someone, we get our own rank lol!
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
11 Jul 2014 09:20 AM
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
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
11 Jul 2014 09:29 AM
Still not working :/
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
11 Jul 2014 09:30 AM
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 <= 50 and 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
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
11 Jul 2014 09:34 AM
The script loads before the player. Try adding a wait(2) at top
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
11 Jul 2014 09:54 AM
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.
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
11 Jul 2014 05:47 PM
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 <= 50 and 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
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
11 Jul 2014 06:23 PM
I was told that LocalScript do not work correctly Online, any idea of how I could convert my LocalScript into a Script?

Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image