I'm trying to get this chat script to work but nothing happens when I put in the commands. I have tried quite a few things. The models are in server storage.
local Flip = game.ServerStorage.Flip
local Fig = game.ServerStorage.Fig
local Fig1 = game.ServerStorage.Fig1
local Fig2 = game.ServerStorage.Fig2
local Fig3 = game.ServerStorage.Fig3
local Fig4 = game.ServerStorage.Fig4
local Relay = game.ServerStorage.Relay
local Double = game.ServerStorage.Double
local Banger = game.ServerStorage.Banger
local Weak = game.ServerStorage.Weak
local group = {
["Player1"] = true;
["TheBeaver101"] = true;
["mattschnegg"] = true;
}
game.Players.PlayerAdded:connect(function(player)
if group[player.Name] then
player.Chatted:connect(function(msg)
if msg == "/Flip" then --T1
local FlipClone = Flip:Clone()
FlipClone.Parent = game.Workspace
FlipClone:MakeJoints()
FlipClone.Name = "FlipClone"
wait(0.5)
end
if msg == "/Remove Flip" then
local FlipClone = game.Workspace.FlipClone
FlipClone:Destroy()
wait(0.5)
end
if msg == "/Fig" then --T2
local FigClone = Fig:Clone()
FigClone.Parent = game.Workspace
FigClone:MakeJoints()
FigClone.Name = "FigClone"
wait(0.5)
end
if msg == "/Remove Fig" then
local FigClone = game.Workspace.FigClone
FigClone:Destroy()
wait(0.5)
end
if msg == "/Fig1" then --T2
local Fig1Clone = Fig1:Clone()
Fig1Clone.Parent = game.Workspace
Fig1Clone:MakeJoints()
Fig1Clone.Name = "Fig1Clone"
wait(0.5)
end
if msg == "/Remove Fig1" then
local Fig1Clone = game.Workspace.Fig1Clone
Fig1Clone:Destroy()
wait(0.5)
end
if msg == "/Fig2" then --T2
local Fig2Clone = Fig2:Clone()
Fig2Clone.Parent = game.Workspace
Fig2Clone:MakeJoints()
Fig2Clone.Name = "Fig2Clone"
wait(0.5)
end
if msg == "/Remove Fig2" then
local Fig2Clone = game.Workspace.Fig2Clone
Fig2Clone:Destroy()
wait(0.5)
end
if msg == "/Fig3" then --T2
local Fig3Clone = Fig3:Clone()
Fig3Clone.Parent = game.Workspace
Fig3Clone:MakeJoints()
Fig3Clone.Name = "Fig3Clone"
wait(0.5)
end
if msg == "/Remove Fig3" then
local Fig3Clone = game.Workspace.Fig3Clone
Fig3Clone:Destroy()
wait(0.5)
end
if msg == "/Fig4" then --T2
local Fig4Clone = Fig4:Clone()
Fig4Clone.Parent = game.Workspace
Fig4Clone:MakeJoints()
Fig4Clone.Name = "Fig4Clone"
wait(0.5)
end
if msg == "/Remove Fig4" then
local Fig4Clone = game.Workspace.Fig4Clone
Fig4Clone:Destroy()
wait(0.5)
end
if msg == "/Relay" then --T1
local RelayClone = Relay:Clone()
RelayClone.Parent = game.Workspace
RelayClone:MakeJoints()
RelayClone.Name = "RelayClone"
wait(0.5)
end
if msg == "/Remove Relay" then
local RelayClone = game.Workspace.RelayClone
RelayClone:Destroy()
wait(0.5)
end
if msg == "/Double" then --T1
local DoubleClone = Double:Clone()
DoubleClone.Parent = game.Workspace
DoubleClone:MakeJoints()
DoubleClone.Name = "DoubleClone"
wait(0.5)
end
if msg == "/Remove Double" then
local DoubleClone = game.Workspace.DoubleClone
DoubleClone:Destroy()
wait(0.5)
end
if msg == "/Banger" then --T1
local BangerClone = Banger:Clone()
BangerClone.Parent = game.Workspace
BangerClone:MakeJoints()
BangerClone.Name = "BangerClone"
wait(0.5)
end
if msg == "/Remove Banger" then
local BangerClone = game.Workspace.BangerClone
BangerClone:Destroy()
wait(0.5)
end
if msg == "/Weak" then
local WeakClone = game.ServerStorage.Weak:Clone()
WeakClone.Parent = game.Workspace
WeakClone:MakeJoints()
WeakClone.Name = "WeakClone"
wait(0.5)
end
if msg == "/Remove Weak" then
local WeakClone = game.Workspace.WeakClone
WeakClone:Destroy()
wait(0.5)
end
end)
end
end)

4 comments
Putting a connection inside an if-statement is totally okay. In fact, it's probably better, because it avoids making unnecessary connections where they aren't required.
You can just put it inside the event, which is the same effect!
I mean yeah, it's pretty much the same, so it doesn't matter - but you're the one arguing for it not being okay. Also, it's actually not the same - putting the if-statement inside the function runs it every time the function is called. It also creates a bunch of connections that will never properly fire, wasting memory. On the other hand, putting it outside runs the if-statement only once.
Thank you so much!