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
 

My script won't work correctly.

Previous Thread :: Next Thread 
bobosaid is not online. bobosaid
Joined: 26 Feb 2011
Total Posts: 10760
24 Dec 2011 09:44 PM
This is a script for a GUI shop thing I am making.
It is supposed to give you the tool when the GUI button pressed and when you have enough kills/KOs.
This is the script

player = script.Parent.Parent.Parent.Parent.Parent
KOs = player.leaderstats.Kills
price = 15
tool = game.Lighting:findFirstChild("LightSword") --this is were you put the weapon name mk simple right it could be ("derpsword")


function buy()
if KOs.Value >= price then
local a = tool:clone()
a.Parent = player.Backpack
local b = tool:clone()
b.Parent = player.StarterGear

end
end
script.Parent.MouseButton1Down:connect(buy)

It works correctly in my head, But doesn't work.
Report Abuse
metaplates is not online. metaplates
Joined: 20 Dec 2011
Total Posts: 423
24 Dec 2011 09:54 PM
Save yourself some trouble. Seriously.
LOCALSCRIPTS.

player = Game.LocalPlayer
KOs = player.leaderstats.Kills
price = 15
tool = game.Lighting:findFirstChild("LightSword")

script.Parent.MouseButton1Down:connect(function(m)
if KOs.Value >= price then
local a = tool:clone()
a.Parent = player.Backpack
local b = tool:clone()
b.Parent = player.StarterGear -- It might be StarterPack.
end)

-They say that love is forever, your forever is all that I need.
Report Abuse
MrCrazyman42 is not online. MrCrazyman42
Joined: 01 Feb 2011
Total Posts: 740
24 Dec 2011 10:02 PM
These might be the errors. I don't do GUI scripts much...




line 2 - KOs = player.Leaderstats.("Kills") - If you don't " it, workspace won't know what it is.

line 4 - tool = game.Lighting:findFirstChild("LightSword") --this is where you put the weapon name (what is the mk word? Scripts can't function right if something doesn't make sense) simple right it could be. - The script won't function right if it doesn't know if it does Lightsword or Derpsword.

That is all I see, you script should look like this :

player = script.Parent.Parent.Parent.Parent.Parent
KOs = player.leaderstats.("Kills")
price = 15
tool = game.Lighting:findFirstChild("LightSword") --this is where you put the weapon name ?? simple right it could be.


function buy()
if KOs.Value >= price then
local a = tool:clone()
a.Parent = player.Backpack
local b = tool:clone()
b.Parent = player.StarterGear

end
end
script.Parent.MouseButton1Down:connect(buy)

Report Abuse
MrCrazyman42 is not online. MrCrazyman42
Joined: 01 Feb 2011
Total Posts: 740
24 Dec 2011 10:04 PM
I don't know. I don't do GUI scripts.
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
24 Dec 2011 10:27 PM
@Metaplates

Um, I believe it's game.Players.LocalPlayer....
Report Abuse
metaplates is not online. metaplates
Joined: 20 Dec 2011
Total Posts: 423
24 Dec 2011 10:29 PM
@DXPower
It was a mistype, excuse me. =]

-They say that love is forever, your forever is all that I need.
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