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: What's wrong with this?

Previous Thread :: Next Thread 
Shadowblacksmith is not online. Shadowblacksmith
Joined: 27 Jul 2009
Total Posts: 6911
12 May 2013 09:41 AM
I'm attempting to make a Loadout GUI using BoolValues stored in player, every time I seem to click on the text button, I get an error, and it disconnects.

sp = script.Parent

function equip(player, click)
    if player:FindFirstChild("SI61B").Value==true then
        player:FindFirstChild("Primary").Value = "SI61B"
    else
        sp.Text = "Weapon not owned"
        wait(1)
        sp.Text = ""
        wait(1)
        sp.Text = "Weapon not owned"
        wait(1)
        sp.Name = sp.Primary.Value
    end
end


script.Parent.MouseButton1Click:connect(player, click)

What am I doing wrong?
Should just say, I am slightly new to this, but I have a vague idea of what I'm doing.
Report Abuse
Shadowblacksmith is not online. Shadowblacksmith
Joined: 27 Jul 2009
Total Posts: 6911
12 May 2013 09:55 AM
Bump.
Report Abuse
Shadowblacksmith is not online. Shadowblacksmith
Joined: 27 Jul 2009
Total Posts: 6911
12 May 2013 10:17 AM
Bump...
Report Abuse
ChangeIing is not online. ChangeIing
Joined: 26 Apr 2012
Total Posts: 25
12 May 2013 10:22 AM
> if player:FindFirstChild("SI61B").Value==true then

--Try it without the .Value==true
--Implying you want to check if the object exists.

if player:FindFirstChild("SI61B") then
Report Abuse
Shadowblacksmith is not online. Shadowblacksmith
Joined: 27 Jul 2009
Total Posts: 6911
12 May 2013 10:24 AM
I should have said this in my first post - You need to buy the weapons from a store before you can use them on your loadout, and that's where checking for the BoolValue being true comes in.
Report Abuse
ChangeIing is not online. ChangeIing
Joined: 26 Apr 2012
Total Posts: 25
12 May 2013 10:29 AM
function equip(player, click)
if player:FindFirstChild("SI61B").Value==true then
player:FindFirstChild("Primary").Value = "SI61B"
else
sp.Text = "Weapon not owned"
wait(1)
sp.Text = ""
wait(1)
sp.Text = "Weapon not owned"
wait(1)
sp.Name = sp.Primary.Value
end
end


Make sure this is correct?:
-There are boolean values put into the character when they enter the game with the names of each weapon and also a string value called Primary placed in the player.

-sp is either a TextLabel or TextButton
-There is also a value in sp called Primary

Might be the problem:
Early in the script, you have:


player:FindFirstChild("Primary")

and later on you have

sp.Primary.Value
Report Abuse
Shadowblacksmith is not online. Shadowblacksmith
Joined: 27 Jul 2009
Total Posts: 6911
12 May 2013 10:31 AM
There's another StringValue in the text button with the weapon's name on it, it's because there's multiple pages. I'll try that out quickly.
Report Abuse
ChangeIing is not online. ChangeIing
Joined: 26 Apr 2012
Total Posts: 25
12 May 2013 10:34 AM
I'm going to log off of ROBLOX so I can't help you beyond this point.
One final note.

Make sure that your locations are correct.

You said the values are in the text button, but your script is searching in the player.
Report Abuse
Shadowblacksmith is not online. Shadowblacksmith
Joined: 27 Jul 2009
Total Posts: 6911
12 May 2013 10:35 AM
There's two 'Primary' values.
One in the player, one in the button.

If this helps, here's the output after I click it...:
16:34:19.451 - attempt to call a nil value
16:34:19.453 - Disconnected event because of exception
Report Abuse
Shadowblacksmith is not online. Shadowblacksmith
Joined: 27 Jul 2009
Total Posts: 6911
12 May 2013 10:56 AM
Bump
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
12 May 2013 11:01 AM
I don't think that the event you're using, gives any arguments.
Report Abuse
Shadowblacksmith is not online. Shadowblacksmith
Joined: 27 Jul 2009
Total Posts: 6911
12 May 2013 11:19 AM
Still can't get it to work.
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
12 May 2013 11:24 AM
script.Parent.MouseButton1Click:connect(equip)
Define player and click manually.
Report Abuse
Shadowblacksmith is not online. Shadowblacksmith
Joined: 27 Jul 2009
Total Posts: 6911
12 May 2013 11:40 AM
I've changed it to this;
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function (player, click)
function equip(player, click)
local gun1 = player:FindFirstChild("SI61B")
local primary1 = player:FindFirstChild("Primary")
if gun1.Value==true then
    primary1.Value = "SI61B"
    else
if gun1.Value==false then
        script.Parent.Text = "Weapon not owned"
        wait(1)
        script.Parent.Text = ""
        wait(1)
        script.Parent.Text = "Weapon not owned"
        wait(1)
        script.Parent.Name = script.Parent.Primary.Value
    end
end
end
end)

It's stopped erroring, but I'm getting nothing back.
Like, it won't change the 'Primary' value to SI61B, nor will the GUI flash 'Weapon not owned'.
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
12 May 2013 11:42 AM
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
local gun1 = player:FindFirstChild("SI61B")
local primary1 = player:FindFirstChild("Primary")
if gun1.Value==true then
primary1.Value = "SI61B"
elseif gun1.Value==false then
script.Parent.Text = "Weapon not owned"
wait(1)
script.Parent.Text = ""
wait(1)
script.Parent.Text = "Weapon not owned"
wait(1)
script.Parent.Name = script.Parent.Primary.Value
end
end)
Report Abuse
Shadowblacksmith is not online. Shadowblacksmith
Joined: 27 Jul 2009
Total Posts: 6911
12 May 2013 12:46 PM
Awesome, works good now.
Only problem is the last bit, (script.Parent.Name = script.Parent.Primary.Value) it's just staying as 'Weapon not owned', but that doesn't matter. I'll find a way around it.
Cheers!
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