Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

String Problem,can anyone help me?

So I am working on a Training Holo and the string wont work! So far a couple of people have helped me out but anyways,heres what I have so far it doesnt seem to be working so I need help!

a=Holo.configuration
b=a.RankId
c=a.GroupId
game.Players.PlayerAdded:connect(function(plr) 
if player:GetRankInGroup(c.Value) >= b.Value then 
player.Chatted:connect(function(msg)
	if string.lower(chat) == "sf" 
game.Lighting.Thing:Clone().Parent = game.Workspace
	elseif string.lower(chat) == "close sf" then
if game.Workspace:FindFirstChild("Thing") then
game.Workspace.Thing:Remove() 
end
	end





	


1 answer

✓ Accepted answer

First, tab and space your code properly.

game.Players.PlayerAdded:connect(function(plr)
	if player:GetRankInGroup(config.GroupId.Value) >= config.RankId.Value then 
		plr.Chatted:connect(function(msg)
			if string.lower(chat) == "sf" then
				if not game.Workspace:FindFirstChild("Thing") then
					game.Lighting.Thing:Clone().Parent = game.Workspace
				end
			elseif string.lower(chat) == "close sf" then
				if game.Workspace:FindFirstChild("Thing") then
					game.Workspace.Thing:Remove()
				end
			end
		end
	end)

You'll see you're missing a final end) and have misplaced the final parenthesis ).


You never defined player (your parameter is plr).


You never defined config.


You should test incrementally. Not write 20 lines and hope it all works. That's a stupid way to do things. Write two lines at a time, and then test. Also, use the output since it would have told you all three of these errors.

14 comments

0

What do you mean by defined?Like variables?

0

Yes. You use both config and player without ever telling Lua what their values are.

0

So I would need to do something like config=game.Workspace.configuration?

0

Yes.

0

What about plr?

0

Replace occurrences of player with plr.

0

How do I do that

0

If you wrote "player" somewhere, write "plr" instead...

0

Alright but did I not have that already?Above plr it has player so does that mean technically I did it?

0

No. That is the mistake I am talking about. You use player but you never define it. plr as a parameter to the function (line 1) acts as a definition for plr. player remains undefined. Use plr always in this script instead.

0

So you suggest I just switch plr to player?

0

It doesn't matter which one you switch to which, but you can only use one of the two in this script.

0

Alright

0

I put a new script in I am having trouble with the ends I think

This discussion is preserved as it was. New answers, comments, and votes are closed.