of     1   

bigpeking
#31286609Tuesday, August 10, 2010 1:06 AM GMT

For some reason, the script doesn't work. It doesn't show an error in output, so I'm not sure what's wrong.
bigpeking
#31286684Tuesday, August 10, 2010 1:07 AM GMT

Whoops, here's the script: local debounce = false function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end function onTouch(part) local human = part.Parent:findFirstChild("Humanoid") if (human ~= nil) and debounce == false then debounce = true local player = getPlayer(human) if (player == nil) then return end person = human.Parent.Name player = game.Players:findFirstChild(person) points = player.leaderstats.Points.Value end if points >= 2 then script.Parent:clone().Parent = player.Backpack player.leaderstats.Points.Value = points - 2 wait(3) debounce = false end end script.Parent.Parent.Touched:connect(onTouch)
LPGhatguy
Forum Moderator
#31286693Tuesday, August 10, 2010 1:07 AM GMT

It sounds quite a bit like a logic error. Maybe you can go to Let's Make a Deal to find a working one?
bigpeking
#31286808Tuesday, August 10, 2010 1:09 AM GMT

Ever since I started to learn to script I sort of vowed to never use free models or stuff from other people unless I COMPLETELY can't do something. I'd like to try to fix the one that I made.
LPGhatguy
Forum Moderator
#31287469Tuesday, August 10, 2010 1:16 AM GMT

Good boy, no free models. *pats on head* I pretty much rewrote yours. local Cost = 2 local debounce = false script.Parent.Parent.Touched:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) debounce = true points = player.leaderstats.Points.Value if (points >= Cost) then player.leaderstats.Points.Value = points - Cost script.Parent:Clone().Parent = player.Backpack end wait(3) debounce = false end end)
LPGhatguy
Forum Moderator
#31287514Tuesday, August 10, 2010 1:16 AM GMT

Woops! Coding in C# has messed up my Lua. Here. ocal Cost = 2 local debounce = false script.Parent.Parent.Touched:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) then debounce = true points = player.leaderstats.Points.Value if (points >= Cost) then player.leaderstats.Points.Value = points - Cost script.Parent:Clone().Parent = player.Backpack end wait(3) debounce = false end end end)
LPGhatguy
Forum Moderator
#31287594Tuesday, August 10, 2010 1:17 AM GMT

Might I try one more time? Sorry for posting 3 times in a row. This one should work, it might need a tad bit of tweaking though. local Cost = 2 local debounce = false script.Parent.Parent.Touched:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) then debounce = true points = player.leaderstats.Points.Value if (points >= Cost) then player.leaderstats.Points.Value = points - Cost script.Parent:Clone().Parent = player.Backpack end wait(3) debounce = false end end end)
bigpeking
#31287716Tuesday, August 10, 2010 1:18 AM GMT

I must thouroughly read and understand it before I use it...
LPGhatguy
Forum Moderator
#31287871Tuesday, August 10, 2010 1:20 AM GMT

It's pretty easy to understand. I'm just changing the way the connection works, and using :GetPlayerFromCharacter instead of searching based on the character's name. I also made your point subtraction and stuff based on a variable. So really, it isn't all that different.
bigpeking
#31287945Tuesday, August 10, 2010 1:21 AM GMT

Oh, ok. Now I just need to fix it up a bit.
LPGhatguy
Forum Moderator
#31288014Tuesday, August 10, 2010 1:22 AM GMT

Yeah, I was too lazy to open up studio and try and make it work on my own. Good luck!
bigpeking
#31288611Tuesday, August 10, 2010 1:28 AM GMT

Grr... I can't figure out how to solve an error message I got. It says "21: ')' expected (to close '(' at line 4) near 'end'"
LPGhatguy
Forum Moderator
#31289045Tuesday, August 10, 2010 1:32 AM GMT

Add a ) at the end of the script. I think you forgot to copy the ).
bigpeking
#31289569Tuesday, August 10, 2010 1:38 AM GMT

Nope, still the same error message.
LPGhatguy
Forum Moderator
#31289613Tuesday, August 10, 2010 1:39 AM GMT

Try adding another until you get a different error.
bigpeking
#31289972Tuesday, August 10, 2010 1:43 AM GMT

After adding about 25 extra )'s and getting the same message every time, I dont think thats the solution.
LPGhatguy
Forum Moderator
#31290027Tuesday, August 10, 2010 1:43 AM GMT

Okay, in that case, I'll go ahead and actually test it.
bigpeking
#31290202Tuesday, August 10, 2010 1:45 AM GMT

Thank you. I wonder what was wrong...
LPGhatguy
Forum Moderator
#31290402Tuesday, August 10, 2010 1:47 AM GMT

Couldn't really find it. Looks like we'll just settle for a non-anonymous function. local Cost = 2 local debounce = false function onTouch(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) then debounce = true points = player.leaderstats.Points.Value if (points >= Cost) then player.leaderstats.Points.Value = points - Cost script.Parent:Clone().Parent = player.Backpack end wait(3) debounce = false end end script.Parent.Parent.Touched:connect(onTouch)
bigpeking
#31290617Tuesday, August 10, 2010 1:50 AM GMT

When I first saw the script I thought the function part looked kinda wierd.
LPGhatguy
Forum Moderator
#31290660Tuesday, August 10, 2010 1:50 AM GMT

Yeah, that's simply a way to do connections when you aren't going to call the function seperate from the event.
bigpeking
#31292142Tuesday, August 10, 2010 2:08 AM GMT

Well, it works now, and I'm happeh.

    of     1