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

I am making a Holo and I need help,Can anyone correct me?

Asked by 10 years ago

So far this is what I have,I already have a Configuration file but I dont know whats wrong

game.Players.ChildAdded:connect(function(player)
player.Chatted:connect(function(chat)
if player:GetRankInGroup(config.GroupId.Value) >= config.RankId.Value then
    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)
end)





1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

First off, you should use the PlayerAddedevent instead of ChildAdded. Also, it would be better to check if they're and admin once the join the game, instead of every time they chat.

game.Players.PlayerAdded:connect(function(plr)
    if player:GetRankInGroup(config.GroupId.Value) >= config.RankId.Value then --I assume config is defined somewhere?
        plr.Chatted:connect(function(msg)

Don't forget to rearrange you ends after making these changes!

0
You helped a bit but what do you mean check if they are an admin? Ex_plore 62 — 10y
0
If they have administrative powers, aka the ability to use the chat commands. " if player:GetRankInGroup(config.GroupId.Value) >= config.RankId.Value then" Perci1 4988 — 10y
0
Checking once as soon as they enter the game will help decease lag instead of checking every time they chat. Perci1 4988 — 10y
0
But I tried it and it didnt work for me Ex_plore 62 — 10y
0
Both ways work, but mine is more efficient. If the script does not work it is another problem. Any output? Perci1 4988 — 10y
Ad

Answer this question