``````Game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(MessageSystem)
If MessageSystem == “BB” then
local GiveBall = game.ReplicatedStorage.Basketball:Clone()
GiveBall.Parent = Player.Backpack
Please, if you want to share some code, make sure to format it using ``````
I assume that this isn’t the entire script?
First off, you need to close the if statement and the function in the chatted event with end
, also “Script” and “If” should be lowercase. I assume that’s a server script so script.Parent
isn’t gonna be a player object
What? What do you mean? lol. What do you mean by that?
I did that I just typed on my phone the whole script, that’s why lower cases and things are there.
Where is your script located? ServerScriptService?
Oops I see I typed it a different way, I still did that in the script though and it didn’t work the first time I did it I did player added then a parameter.
Yes it is in the server script.
--script in ServerScriptService
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
msg = string.lower(msg)
if msg == "ball" then
local clone = game:GetService("ReplicatedStorage").Basketball:Clone()
clone.Parent = plr.Backpack
end
end)
end)
game:GetService'Players'.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message == "BB" then
local GiveBall = game.ReplicatedStorage.Basketball:Clone()
GiveBall.Parent = Player.Backpack
end
end)
end)
:GetService(“Players”) does not change anything.
Can it be Plr Because a lot of my friends were telling me my script error because of that and I tried it Player by the way I missed spelled my script was actually like this
game.players:PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(MessageSystem)
If MessageSystem == “BB” then
local GiveBasketball = game:ReplicatedStorage.Basketball:Clone()
GiveBasketball.Parent = Player.Backpack —still got error.
It can be plr
or player
. The code that was sent should be working fine.
I like it but what is GetService going to change?
Oh but pretty weird I get error.
It would help if you showed what exactly the error says
I didn’t receive any error when I tested the script - could you specify it? Did you implement the source code into a script
that’s parented in ServerScriptService?
You know what I forgot to put the script in serverscriptservice lol.
You won’t be receiving an error when you change the parameter name whatsoever.
Yield the function until the server detects the folder location. Use WaitForChild()
GiveBasketball.Parent = Player:WaitForChild("Backpack")
And also due to cheat, you can move the basketball to ServerStorage so it won’t get cloned by the exploiter’s client.
So this script may help you.
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message == "BB" then
local Ball = game:GetService("ServerStorage").Basketball:Clone()
Ball.Parent = Player:WaitForChild("Backpack")
end
end)
end)