local plr = game.Players.LocalPlayer local fo = game.ReplicatedStorage.Football game.Players.PlayerAdded:Connect(function(plr) -- Detects player joining and stores player object at the var "plr" plr.Chatted:connect(function(msg) -- Detects when a player chats and stores the message to the var "msg" msg = msg:lower() if (msg == ":give me fo") then-- Checks if what player chatted is the command(in this case, startgam --start the game fo:Clone() fo:Clone().Parent = plr end
ServerScriptService.Script:10: Expected 'end' (to close 'function' at line 4), got <eof>; did you forget to close 'then' at line 6? Error
Try this:
local plr = game.Players.LocalPlayer local fo = game.ReplicatedStorage.Football local prefix = ':' game.Players.PlayerAdded:Connect(function(plr) plr.Chatted:connect(function(msg) msg = msg:lower() if string.sub(msg, 1, 11) == prefix..'give me fo' then fo:Clone() fo:Clone().Parent = plr end end) end)
or try this:
local plr = game.Players.LocalPlayer local fo = game.ReplicatedStorage.Football local prefix = ':' game.Players.PlayerAdded:Connect(function(plr) plr.Chatted:connect(function(msg) msg = msg:lower() if msg == prefix..'give me fo' then fo:Clone() fo:Clone().Parent = plr end end) end)
1 - You can't use 'game.Players.LocalPlayer' from server scripts,
2 - You need close your functions
try it and should work
local Players = game:GetService("Players") local fo = game.ReplicatedStorage.Football Players.PlayerAdded:Connect(function(plr) plr.Chatted:Connect(function(msg) msg = msg:lower() print(msg) if (msg == ":give me fo") then fo:Clone() fo:Clone().Parent = plr end end) end)
Try This One
local plr = game.Players.LocalPlayer local fo = game.ReplicatedStorage.Football game.Players.PlayerAdded:connect(function(player) if player.Name == "Player" then player.Chatted:connect(function(msg) if msg:lower() == ":give me fo" then local fooo = fo:Clone() fooo.Parent = plr.Backpack --You forgot the Backpack mate end end) end end)