|
| 13 Aug 2013 05:30 AM |
Here's my entire script:
sp = script.Parent RewardGold = sp.Parent.Parent.Objective.Settings.GoldReward.Value RewardXP = sp.Parent.Parent.Objective.Settings.XPReward.Value
function close() game.Players.LocalPlayer.leaderstats.Gold.Value = game.Players.LocalPlayer.leaderstats.Gold.Value + RewardGold game.Players.LocalPlayer.leaderstats.XP.Value = game.Players.LocalPlayer.leaderstats.XP.Value + RewardXP sp.Parent.Parent.Position = UDim2.new(0.5, -125, 1, 0) sp.Parent.Parent.Visible = false sp.Parent.Parent.Objective.Settings.Finished.Value = true end sp.MouseButton1Click:connect(close)
It gives no errors, and also doesn't award any gold or experience when clicked... Tested in "Start Server" -> "Start Character" and also using normal play mode. Anyone know what the issue might be?
All the best, filiptibell |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 13 Aug 2013 06:00 AM |
Hm. I don't see any syntax errors. So I assume it might be some objects placed wrong or whatever could be the problem.
Have you tried looking in the Output window for errors that might help? http://wiki.roblox.com/index.php/Output http://wiki.roblox.com/index.php/Lua_errors
Also, 2 things that makes me worry is that... ohwell, nearly no one has protection on their leaderboards (except for people like Shedletsky and whoever don't want trouble)... nah, just forget it. xP
- As, I dun think we're allow'd to make decals showing the structure of a model. Derpit. Roblox imag' mods! D: |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2013 06:11 AM |
I put a print statement before the connection line, and it got printed just fine. The output doesn't give any errors either when I test it using Start Server (checked the player output+ servers output) If anything was placed wrong it should have told me that "... is not a member of ...", no? This is really confusing. :( |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 13 Aug 2013 06:28 AM |
Hm, when I got such problems, I added tons of prints. To find out on just which line the script stopped...
So try use this:
print("Test 1") sp = script.Parent RewardGold = sp.Parent.Parent.Objective.Settings.GoldReward.Value RewardXP = sp.Parent.Parent.Objective.Settings.XPReward.Value print("Test 2")
function close() print("Test 4") game.Players.LocalPlayer.leaderstats.Gold.Value = game.Players.LocalPlayer.leaderstats.Gold.Value + RewardGold game.Players.LocalPlayer.leaderstats.XP.Value = game.Players.LocalPlayer.leaderstats.XP.Value + RewardXP print("Test 5") sp.Parent.Parent.Position = UDim2.new(0.5, -125, 1, 0) sp.Parent.Parent.Visible = false sp.Parent.Parent.Objective.Settings.Finished.Value = true print("Test 6") end sp.MouseButton1Click:connect(close) print("Test 3")
If only the 3 first tests appear, even after clicking the GuiButton, then it's either not visible or... something else...
- As, I got a bad feeling about what I said some months ago. |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2013 06:34 AM |
They all get printed, but still no gold gets added.. :/
~The derp lerped a herp.~ |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 13 Aug 2013 06:38 AM |
Then I think that:
sp.Parent.Parent.Objective.Settings.GoldReward.Value and sp.Parent.Parent.Objective.Settings.XPReward.Value
is 0 when you run the script.
If you want to change their values later on, I suggest something like:
sp = script.Parent RewardGold = sp.Parent.Parent.Objective.Settings.GoldReward RewardXP = sp.Parent.Parent.Objective.Settings.XPReward
function close() game.Players.LocalPlayer.leaderstats.Gold.Value = game.Players.LocalPlayer.leaderstats.Gold.Value + RewardGold.Value game.Players.LocalPlayer.leaderstats.XP.Value = game.Players.LocalPlayer.leaderstats.XP.Value + RewardXP.Value sp.Parent.Parent.Position = UDim2.new(0.5, -125, 1, 0) sp.Parent.Parent.Visible = false sp.Parent.Parent.Objective.Settings.Finished.Value = true end sp.MouseButton1Click:connect(close)
- As, IRC you say, Poe? |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2013 06:50 AM |
I made a model of the of the whole objective GUI: http://www.roblox.com/ObjectiveGUI-item?id=126222800
I also checked if those values were correct, and they were. XPReward was supposed to be 0 and GoldReward 100, and they both were :/
Would you mind checking out the model and see if there is anything wrong? (You will probably need to make a temporay leaderboard with values named "Gold", "Lvl" and "XP")
~The derp lerped a herp.~ |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 13 Aug 2013 07:10 AM |
Looked though your scripts, made a leaderboard and whatever required and tried printing RewardGold and RewardXP.
As I thought, the were both zero.
GUI > Objective >> Settings >> GoldReward >> XPReward
both of them have a value of 0.
Also, I recommend that you use serversided scripts to secure your game against exploiters. Saving important data in [Stuff]Value should not be used unless it makes the game faster & easier to develop further.
- As, while wait(5) do print("5 seconds elapsed since last print!") end |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2013 07:27 AM |
Apparently the values were messing with me, I don't know why but they appeared correct while they were both 0. (Ran 2 print statements, they both printed 0. -_-)
Fixed it by adding these 2 lines (also inserted new NumberValues and named them again just to maked sure): sp.Objective.Settings.GoldReward.Value = 100 sp.Objective.Settings.XPReward.Value = 0
At the start of the script instead of inside the "while ...stats.Lvl.Value < 5 do" loop. And yes, this whole GUI with the settings thing was made that way so that it would be easier to make new "Objectives". :P
Thanks for the help!
~The derp lerped a herp~ |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2013 07:29 AM |
| I feel completely dumb, :) |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2013 07:36 AM |
Oh and there were actually 2 problems, the other being that you can't adress the value directly with a variable: RewardGold = sp.Parent.Parent.Objective.Settings.GoldReward.Value
So I just removed "Value" and used this line when adding the "gold": game.Players.LocalPlayer.leaderstats.Gold.Value + RewardGold.Value
That was probably the main issue. Again, thanks for helping! :)
~The derp lerped a herp~ |
|
|
| Report Abuse |
|
|