Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How come one of the commands in my script aren't working?

Asked by 10 years ago

Its the 'c/' command, it isn't working, it keeps saying Failed to create script! :(, I have tested it, and changed a few things, but still is not working, and there is nothing coming up in the Output, here is the script;

local Admins = {"TheeDeathCaster","TheAlphaStigma","DeathWindZombie"}

function chkAdmin(str)
for i = 1, #Admins do if str.Name:lower() == Admins[i]:lower() then return true end end
return false
end

function Message(msg,time,par,type)
local m = Instance.new(type)
m.Parent = par
for i = 1, #msg do
m.Text = tostring(string.sub(msg,1,i))
wait(0.07)
end
wait(time)
if m ~= nil then
m:Destroy()
end
end

function findPlayer(str)
for i,v in pairs(game.Players:GetPlayers())do
if v and v.Name:lower():find(str:lower())then
return v
end
end
end

local function onScript(codeString,newParent,timeBeforeRemoval)
local newString = Instance.new("StringValue")
newString.Value = codeString
newString.Parent = newParent
while newString.Value ~= codeString and newString.Parent ~= newParent do wait(0)end
loadstring(newString.Value)();
wait(timeBeforeRemoval)
newString:Destroy()
end

function onChat(msg,speaker)

if msg:lower():sub(1,5) == "kill/"then
local getPlr = findPlayer(msg:sub(6))
if getPlr and getPlr.Character and speaker.PlayerGui and not chkAdmin(getPlr,false) then
getPlr.Character:BreakJoints()
Message("Killed "..getPlr,2,speaker.PlayerGui,"Hint")
elseif not getPlr then
Message("Player "..msg:sub(6).." not existant, or not ingame",2,speaker.PlayerGui,"Hint")
elseif chkAdmin(getPlr,false)then
Message("Player "..msg:sub(6).." is an Admin",2,speaker.PlayerGui,"Hint")
end
end

if msg:lower():sub(1,2) == "c/" then --Isn't working
if not chkAdmin(speaker,false)and speaker.PlayerGui then
onScript(msg:sub(3),nil,2)
Message("Successfully made script!",2,speaker.PlayerGui,"Hint")
else
Message("Failed to create script! :(",2,speaker.PlayerGui,"Hint")
end
end

if msg:lower() == "test"then
Message("Message complete! Admin working!",2,speaker.PlayerGui,"Hint")
end

end

game.Players.PlayerAdded:connect(function(plr)
for i,v in pairs(Admins)do
if plr.Name:lower() == v:lower()then
Message("Your an admin, "..plr.Name.."!",2,plr:FindFirstChild("PlayerGui",true),"Message")
plr.Chatted:connect(function(msg)
onChat(msg,plr)
end)
end
end
end)

1 answer

Log in to vote
2
Answered by
Nickoakz 231 Moderation Voter
10 years ago
local Admins = {"TheeDeathCaster","TheAlphaStigma","DeathWindZombie"}

function chkAdmin(str)
for i = 1, #Admins do if str.Name:lower() == Admins[i]:lower() then return true end end
return false
end

function Message(msg,time,par,type)
local m = Instance.new(type)
m.Parent = par
for i = 1, #msg do
m.Text = tostring(string.sub(msg,1,i))
wait(0.07)
end
wait(time)
if m ~= nil then
m:Destroy()
end
end

function findPlayer(str)
for i,v in pairs(game.Players:GetPlayers())do
if v and v.Name:lower():find(str:lower())then
return v
end
end
end

local function onScript(codeString,newParent,timeBeforeRemoval)
local newString = Instance.new("StringValue")
newString.Value = codeString
newString.Parent = newParent
while newString.Value ~= codeString and newString.Parent ~= newParent do wait(0)end
loadstring(newString.Value)();
wait(timeBeforeRemoval)
newString:Destroy()
end

function onChat(msg,speaker)

if msg:lower():sub(1,5) == "kill/"then
local getPlr = findPlayer(msg:sub(6))
if getPlr and getPlr.Character and speaker.PlayerGui and not chkAdmin(getPlr,false) then
getPlr.Character:BreakJoints()
Message("Killed "..getPlr,2,speaker.PlayerGui,"Hint")
elseif not getPlr then
Message("Player "..msg:sub(6).." not existant, or not ingame",2,speaker.PlayerGui,"Hint")
elseif chkAdmin(getPlr,false)then
Message("Player "..msg:sub(6).." is an Admin",2,speaker.PlayerGui,"Hint")
end
end

if msg:lower():sub(1,2) == "c/" then --Isn't working
if chkAdmin(speaker)and speaker.PlayerGui then --Remove NOT.
onScript(msg:sub(3),nil,2)
Message("Successfully made script!",2,speaker.PlayerGui,"Hint")
else
Message("Failed to create script! :(",2,speaker.PlayerGui,"Hint")
end
end

if msg:lower() == "test"then
Message("Message complete! Admin working!",2,speaker.PlayerGui,"Hint")
end

end

game.Players.PlayerAdded:connect(function(plr)
for i,v in pairs(Admins)do
if plr.Name:lower() == v:lower()then
Message("Your an admin, "..plr.Name.."!",2,plr:FindFirstChild("PlayerGui",true),"Message")
plr.Chatted:connect(function(msg)
onChat(msg,plr)
end)
end
end
end)

You were checking if someone was admin, it returned true, but if it was NOT.

0
Oh, thanks bro! :D TheeDeathCaster 2368 — 10y
Ad

Answer this question