For a game I'm working on, I need to develop a script that can do this:
- Chat commands that anybody can use in order to be given a set of 3 or more tools. (e.i., saying "/knight" and then being given 3 tools for the knight.)
- Chat commands that only people with a game pass can use in order to be given a set of 3 or more tools. -Take the tools from ServerStorage where they're being kept.
I tried modifying this script to be able to do something like it. It's a pretty blank slate as far as it goes, but it also has a built-in gamepass-exclusive command section. I tried modifying it myself, but it didn't pan out correctly. Anybody here know how I could get it to work the way I need to? Any and all tips are very much appreciated.
Inside are the commands that it can do, as examples.
function onChatted(msg, speaker)
local source = string.lower(speaker.Name)
msg = string.lower(msg)
if msg == "!respawn" then
speaker:LoadCharacter()
elseif msg == "!sparkles" then
Instance.new("Sparkles", speaker.Character.HumanoidRootPart)
elseif msg == "!ff" then
Instance.new("ForceField", speaker.Character)
elseif msg == "!run" then
speaker.Character.Humanoid.WalkSpeed = 25
elseif msg == "!walk" then
speaker.Character.Humanoid.WalkSpeed = 16
elseif msg == "!sit" then
speaker.Character.Humanoid.Sit = true
end
end
game.Players.PlayerAdded:connect(function(player)
-- if Game:GetService("GamePassService"):PlayerHasPass(player, INSERT_GAMEPASS_ID_HERE) then
player.Chatted:connect(function(msg) onChatted(msg, player) end)
-- end
end)
-- Remove the "--" abovee if you want the players to have a gamepass, and replace "INSERT_GAMEPASS_ID_HERE" with the gamepass id.

1 comment
The tools are just some models i got as examples