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

When I type the command out nothing happens, how can I fix this?

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 ; did you forget to close 'then' at line 6? Error

1 comment

0

Line 9, you forgot the backpack

3 answers

✓ Accepted answer

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)

1 comment

0

Thank you!!!

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)

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