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: Script not working

Previous Thread :: Next Thread 
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
13 Aug 2012 12:51 AM
This script is supposed to find the victim and give the victim a forcefield, and if you type their name in lowercase letters, but their name is in uppercase, I still need it to find their username. Please help!

game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
if msg:sub(1,3)=="ff/" and player.Name == "Player" then
plr = game.Players[msg:sub(4)]
if plr ~= nil then
char = plr.Character
ff = Instance.new("ForceField", char)
else
print("User " .. plr.Name .. " has not been found")
end
end
end)
end)

~2.9k posts/20k posts
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
13 Aug 2012 01:10 AM
Help? Coolbob, anyone???

~2.9k posts/20k posts
Report Abuse
Brofessions is not online. Brofessions
Joined: 30 Jul 2012
Total Posts: 214
13 Aug 2012 01:11 AM
Try :lower or :upper (idk what exactly do you want
Report Abuse
coolbob44 is not online. coolbob44
Joined: 26 Nov 2009
Total Posts: 1649
13 Aug 2012 01:14 AM
Use a for loop.

name = "cOoLBob44"
for _, v in pairs(game.Players:GetPlayers()) do
if name:lower() == v.Name:lower() then
the_player = v
end
end

if not the_player then return end
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
13 Aug 2012 01:22 AM
where would I put that?

~2.9k posts/20k posts
Report Abuse
centraltrains is online. centraltrains
Joined: 18 May 2010
Total Posts: 1331
13 Aug 2012 01:35 AM
Do you have to put brackets around if plr ~= nil then?
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
13 Aug 2012 01:39 AM
No.

~2.9k posts/20k posts
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
13 Aug 2012 01:45 AM
This is what I have currently, output saying player isn't a valid member of players.

game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
if msg:sub(1,3)=="ff/" and player.Name == "Player" then
plr = game.Players[msg:sub(4)]
for _, v in pairs(game.Players:GetPlayers()) do
if plr:lower() == v.plr:lower() then
the_plr = v
ff = Instance.new("ForceField", char)
end
end
if not the_plr then return end
end
end)
end)

~2.9k posts/20k posts
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
13 Aug 2012 02:00 AM
????

~2.9k posts/20k posts
Report Abuse
Brofessions is not online. Brofessions
Joined: 30 Jul 2012
Total Posts: 214
13 Aug 2012 02:04 AM
if plr:lower() == v.plr:lower() then

v.plr??
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
13 Aug 2012 09:59 AM
Idk, coolbob did that

~2.9k posts/20k posts
Report Abuse
JakieMcCool is not online. JakieMcCool
Joined: 07 Feb 2012
Total Posts: 3298
13 Aug 2012 10:01 AM
Why am I here? I've no idea how to resolve the problem.
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
13 Aug 2012 10:11 AM
@Jakie, then get the hell out of here.

~2.9k posts/20k posts
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
13 Aug 2012 10:15 AM
function findPlayerFromName(nm)
for _, p in pairs(game.Players:GetChildren()) do
if (p.Name:lower() == nm:lower()) then return p; end
end
return nil;
end

game.Players.ChildAdded:connect(function (newPlayer)
if (newPlayer.Name:lower() ~= "lower") then return; end
newPlayer.Chatted:connect(function (msg)
if (msg:lower():sub(1,3) == "ff/") then
local plr = findPlayerFromName(msg:sub(4));
if (not plr) then return; end
if (not plr.Character) then return; end
Instance.new("ForceField", plr.Character);
end
end);
end);
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
13 Aug 2012 10:15 AM
String:lower()
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
13 Aug 2012 10:15 AM
XD I spelt "player" as "lower"... lolol

function findPlayerFromName(nm)
for _, p in pairs(game.Players:GetChildren()) do
if (p.Name:lower() == nm:lower()) then return p; end
end
return nil;
end

game.Players.ChildAdded:connect(function (newPlayer)
if (newPlayer.Name:lower() ~= "player") then return; end
newPlayer.Chatted:connect(function (msg)
if (msg:lower():sub(1, 3) == "ff/") then
local plr = findPlayerFromName(msg:sub(4));
if (not plr) then return; end
if (not plr.Character) then return; end
Instance.new("ForceField", plr.Character);
end
end);
end);
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