|
| 24 Mar 2012 02:38 PM |
function onChatted(msg, recipient, speaker)
local source = string.lower(speaker.Name) msg = string.lower(msg)
if (source ~= "TheSoMekTime") then return end
if string.match(msg, "givepoints/") then local p = game.Players:children() for i = 1, #p do if string.match(msg, string.lower(p[i].Name)) then p[i].leaderstats.Points.Value= p[i].leaderstats.Points.Value + 50 end end end end
function playerAdded(player) player.Chatted:connect(onChatted) end
game.Players.PlayerAdded:connect(playerAdded) |
|
|
| Report Abuse |
|
|
adjotur
|
  |
| Joined: 10 Oct 2011 |
| Total Posts: 892 |
|
|
| 24 Mar 2012 02:40 PM |
| if (source ~= "thesomektime") then return end |
|
|
| Report Abuse |
|
|
| |
|
|
| 24 Mar 2012 03:04 PM |
| Thanks rangersmash, I'll go test it out now. |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 24 Mar 2012 03:05 PM |
| Rangersmash's script shouldn't work. |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2012 03:09 PM |
You're right, it didn't. Btw sorry this is the PROPER script.
function onChatted(msg, recipient, speaker)
local source = string.lower(speaker.Name) msg = string.lower(msg)
if (source ~= "TheSoMekTime") then return end
if string.match(msg, "/givepoints") then local p = game.Players:children() for i = 1, #p do if string.match(msg, string.lower(p[i].Name)) then p[i].leaderstats.money.Value= p[i].leaderstats.money.Value + 100 --Just this line changed to "money" because in the leaderboard it is the money Value not Points. end end end end
function playerAdded(player) player.Chatted:connect(onChatted) end
game.Players.PlayerAdded:connect(playerAdded) |
|
|
| Report Abuse |
|
|
gamehero
|
  |
| Joined: 12 Jun 2007 |
| Total Posts: 1455 |
|
|
| 24 Mar 2012 04:00 PM |
Normally I test this stuff before I post them.. But I think I found the problem.. "speaker" was returning "nil" causing the script to end immediantly on line 6-7.
Hopefully I fixed it now...
function onChatted(msg, recipient, speaker)
local source = string.lower(speaker.Name) msg = string.lower(msg)
if (source ~= "TheSoMekTime") then return end
if string.match(msg, "/givepoints") then local p = game.Players:children() for i = 1, #p do if string.match(msg, string.lower(p[i].Name)) then p[i].leaderstats.money.Value= p[i].leaderstats.money.Value + 100 --Just this line changed to "money" because in the leaderboard it is the money Value not Points. end end end end
function playerAdded(player) player.Chatted:connect(function(msg,rec) onChatted(msg,rec,player) end) end
game.Players.PlayerAdded:connect(playerAdded)
|
|
|
| Report Abuse |
|
|
| |
|
headjoe2
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 971 |
|
|
| 24 Mar 2012 05:36 PM |
| if the source ISNT you, then it will end the function lol |
|
|
| Report Abuse |
|
|
headjoe2
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 971 |
|
|
| 24 Mar 2012 05:41 PM |
try this instead:
if (source == "TheSoMekTime") then return end
on tha one line, it made it work for everybody BUT you. you did this:
if (source ~= "TheSoMekTime") then return end
notice the ~= and == difference? |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 01:49 AM |
| I'll go test all these theories out now and tell you guys what happened. |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 01:57 AM |
| Btw I want the script to work only by me. So wouldn't it be "==" or would it stay "~="? |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 02:04 AM |
Your theories didn't work guys, I don't know if this would be any help to you but here is my leaderboard script.
game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model", player) leaderstats.Name = "leaderstats"
local money = Instance.new("IntValue", leaderstats) money.Name = "Money" money.Value = 0 end) |
|
|
| Report Abuse |
|
|
| |
|
Phellem
|
  |
| Joined: 04 Aug 2011 |
| Total Posts: 1984 |
|
|
| 25 Mar 2012 02:49 AM |
@headjoe2,
You read the code wrong... Don't be so conceited because 2/3 of the time, you're wrong. |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 06:03 AM |
| Do you think you can fix the code Phellem? |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Mar 2012 01:17 PM |
You put source as string.lower(Speaker.Name) but the thing is you put it in caps error much? |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 01:19 PM |
function onChatted(msg, recipient, speaker) local source = string.lower(speaker.Name) msg = string.lower(msg) if (source ~= "thesomektime") then return end if string.match(msg, "givepoints/") then local p = game.Players:children() for i = 1, #p do if string.match(msg, string.lower(p[i].Name)) then p[i].leaderstats.Points.Value= p[i].leaderstats.Points.Value + 50 end end end end function playerAdded(player) player.Chatted:connect(onChatted) end game.Players.PlayerAdded:connect(playerAdded) |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 01:24 PM |
| Caps error? I don't see the caps error in mine. |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 01:25 PM |
local source = string.lower(speaker.Name) msg = string.lower(msg) if (source ~= "TheSoMekTime") then return end
Your lowering the speaker's name and source will never equal TheSoMekTime because you lowered the speaker's name -.- |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Mar 2012 01:28 PM |
| I get it, wow all that and it was just that? I kept capitalizing my name EVERYTIME. Wow... |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 01:37 PM |
OK - It still doesn't work, this is my script EXACTLY how it is now.
function onChatted(msg, recipient, speaker) local source = string.lower(speaker.Name) msg = string.lower(msg) if (source ~= "thesomektime") then return end if string.match(msg, "givemoney/") then local p = game.Players:children() for i = 1, #p do if string.match(msg, string.lower(p[i].Name)) then p[i].leaderstats.money.Value= p[i].leaderstats.money.Value + 100 end end end end function playerAdded(player) player.Chatted:connect(onChatted) end game.Players.PlayerAdded:connect(playerAdded) |
|
|
| Report Abuse |
|
|
| |
|