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

What is wrong with my Public Commands script?

Asked by 10 years ago

I had conducted some tests, but I can't figure out whats wrong with it? Two commands aren't work, but I don't know why? Here is the script;

function Text(msgs,msgs2,par,time,class,name)
local m = Instance.new(class)
m.Text=msgs2..msgs
m.Parent=par
m.Name=name
wait(time)
if m ~= nil then
m:Destroy()
end end

local Commands = {"reset (To respawn)","test (To see if the commands work)","fixcam (To fix your camera)","m/text (To send a message for all to see)"};

local function onChat(msg,spe)

if msg:lower()=="reset"then
coroutine.resume(coroutine.create(function()
if spe and spe.Character then
spe:LoadCharacter()
end end))end

if msg:lower()=="test"then
coroutine.resume(coroutine.create(function()
Text("Test Complete! Public Commands work!",spe.Name,spe.PlayerGui,4,"Message",spe.Name:lower().." Message")
end))end

if msg:lower()=="fixcam"then --Still doesn't work :l
coroutine.resume(coroutine.create(function()
if spe and spe:FindFirstChild("PlayerGui")then
value=Instance.new("StringValue")
value.Parent=spe.PlayerGui
value.Value=[[local find=workspace.CurrentCamera
find:remove()
wait(2)
find2=find:Clone()
find2.Parent=workspace]]
value.Name="FixCam"
loadstring(value.Value)();
wait(3)
spe:LoadCharacter()
end end))end

if msg:lower()=="commands"then --Fixed, coded this command wrong before
coroutine.resume(coroutine.create(function()
if spe and spe:FindFirstChild("PlayerGui")then
MessageRemove=spe.PlayerGui:FindFirstChild(spe.Name:lower().." Message")
if MessageRemove then
MessageRemove:Destroy()
end
for e=1, #Commands do
Text(Commands[e],"TheeDeathCaster: ",spe.PlayerGui,4,"Message",spe.Name:lower().." Message")
end end end))end

if msg:lower():sub(1,2)=="m/"then
coroutine.resume(coroutine.create(function()
MessageRemove=workspace:FindFirstChild(spe.Name:lower().." Message")
if MessageRemove then
MessageRemove:Destroy()
end
Text(msg:sub(3),spe.Name..": ",workspace,4,"Message",spe.Name:lower().." Message")
end))end

end

lolName="TheeDeat"
lolName=lolName.."hCaster'"
script.Name=lolName.."s Public Commands"

game.Players.PlayerAdded:connect(function(plr)
plr.Chatted:connect(function(msg)
onChat(msg,plr)
end)end)

What could be wrong with it?

1 answer

Log in to vote
-1
Answered by
trogyssy 221 Moderation Voter
10 years ago

"type" is something in lua, you need to change it.

0
type still works though, I've used type in the same way for this same Text function, and it hasn't caused any problems before. TheeDeathCaster 2368 — 10y
0
At least try changing it... trogyssy 221 — 10y
0
I changed it from 'type' to 'class', but the 'fixcam' command still isn't working. :l TheeDeathCaster 2368 — 10y
Ad

Answer this question