I dont understand, i tried to give the player something when they say "sword" but it did not work
Code:
game.Players.PlayerAdded:Connect(function(player) player.Chatted:Connect(function(msg) if msg == "sword" then local original = game.ServerStorage.R6Sword local copy = original:Clone() copy.Parent = game.Players.LocalPlayer.Backpack end end) end)
Well first thing, I see you're using LocalPlayer
, there is 2 problems with this:
LocalScript
, it will not be replicated in the server
ServerStorage
, LocalScripts
cannot access ServerStorage
Plus, it isn't necessary, as we already have the player
variable
So instead, put your code in a normal script
, here's a version that should work:
local CallMsg = "sword" local item = game.ServerStorage.R6Sword game.Players.PlayerAdded:Connect(function(player) player.Chatted:Connect(function(msg) if msg == CallMsg then local original = item local copy = original:Clone() copy.Parent = player.Backpack end end) end)
You can place this script in ServerScriptService
if you'd like
Oh and btw, I recommend using ReplicatedStorage
to store tools.