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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How would I go about making a weapon display system

Previous Thread :: Next Thread 
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 02:02 PM
So I am looking to make a GUI and script that displays which weapon is equipped, so then how would I look to access the weapon, for example, find out which weapon the player has equipped.
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 02:14 PM
Bump
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
02 Feb 2016 02:22 PM
Just some pseudo code. If that's the right word :p


local function GetWeaponEquipped()
for i,v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
if v:IsA("Tool") then
return v.Name
end
end
end


print(GetWeaponEquipped())


This would either print nil, if there is no weapon equipped, or it would print the name of the tool that was equipped.
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 02:24 PM
Thanks that's very helpful :)
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
02 Feb 2016 02:26 PM
I'm glad it helps. :-)
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 02:37 PM
local function GetWeaponEquipped()
for i,v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
if v:isA("Tool") then
return v.Name
end
end
end

WepName = script.Parent.Frame.Text.Equipped

WepName.Text = v.Name

So this is why I briefly came up with, however it does not work, how can I make this work?
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 02:41 PM
bump
Report Abuse
LilMcManiac is not online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
02 Feb 2016 02:41 PM
WelpName.Text = GetWeaponEquipped()
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 02:42 PM
Made some changes however the script is still not working :/ here are the changes

local function GetWeaponEquipped()
for i,v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
if v:isA("Tool") then
return v.Name
end

local WepName = script.Parent.Frame.Text.Equipped

WepName.Text = v.Name

end
end
Report Abuse
iPadAviation is not online. iPadAviation
Joined: 09 Feb 2014
Total Posts: 125
02 Feb 2016 02:42 PM
Did you use a localScript?
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
02 Feb 2016 02:43 PM
local function GetWeaponEquipped()
for i,v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
if v:isA("Tool") then
return v.Name
end
end
end

local WepName = script.Parent.Frame.Text.Equipped

WepName.Text = GetWeaponEquipped()
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 02:45 PM
I used a script
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 02:50 PM
bump. It still seems to not be working :/
Report Abuse
vastqud is not online. vastqud
Joined: 10 Sep 2011
Total Posts: 2464
02 Feb 2016 02:53 PM
put that into a localscript
Report Abuse
Exterity is not online. Exterity
Joined: 19 Dec 2009
Total Posts: 4504
02 Feb 2016 02:54 PM
how did you learn to script lua
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 02:55 PM
I already put it into a local script but it still was not working.
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 03:02 PM
bump
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
02 Feb 2016 03:05 PM
errors?



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$329 Tx504 (づ ゚ ³ ゚)づ
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 03:06 PM
bump2.
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 03:07 PM
I dun goofed and entirely forgot to check error messages, but this is what I got
"Players.Player1.PlayerGui.Weapon Display.LocalScript:11: bad argument #3 to 'Text' (string expected, got nil)"
Report Abuse
vastqud is not online. vastqud
Joined: 10 Sep 2011
Total Posts: 2464
02 Feb 2016 03:10 PM
Equipped.Name
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 03:12 PM
Still it is not working :/
Report Abuse
LilMcManiac is not online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
02 Feb 2016 03:13 PM
WelpName = tostring(GetWeaponEquipped())
Report Abuse
vastqud is not online. vastqud
Joined: 10 Sep 2011
Total Posts: 2464
02 Feb 2016 03:13 PM
any more errors?
Report Abuse
ferano is not online. ferano
Joined: 23 Nov 2008
Total Posts: 5094
02 Feb 2016 03:16 PM
No more errors
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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