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

String Problem,can anyone help me?

Asked by 10 years ago

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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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.

0
What do you mean by defined?Like variables? Ex_plore 62 — 10y
0
Yes. You use both `config` and `player` without ever telling Lua what their values are. BlueTaslem 18071 — 10y
0
So I would need to do something like config=game.Workspace.configuration? Ex_plore 62 — 10y
0
Yes. BlueTaslem 18071 — 10y
View all comments (10 more)
0
What about plr? Ex_plore 62 — 10y
0
Replace occurrences of `player` with `plr`. BlueTaslem 18071 — 10y
0
How do I do that Ex_plore 62 — 10y
0
If you wrote "player" somewhere, write "plr" instead... BlueTaslem 18071 — 10y
0
Alright but did I not have that already?Above plr it has player so does that mean technically I did it? Ex_plore 62 — 10y
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. BlueTaslem 18071 — 10y
0
So you suggest I just switch plr to player? Ex_plore 62 — 10y
0
It doesn't matter which one you switch to which, but you can only use one of the two in this script. BlueTaslem 18071 — 10y
0
Alright Ex_plore 62 — 10y
0
I put a new script in I am having trouble with the ends I think Ex_plore 62 — 10y
Ad

Answer this question