Creating a player zone command

There is a lot of things that I do not know about scripting and this is one of them!

How would I go about creating a scripted chat command that creates a circle or square ‘zone’ at the feet of a player that changes in size in studs and follows the player? I have seen some people written similar scripts but I have no clue how I could start at tackling this.

What the script does is simple. You type in the command in chat with ‘!’ or ‘?’ as its prefix, you put in parts of the users name for example ‘?zone theone’ and you finish it off with the size of the zone. This only shows for just the person that is using the command too so no one else can see it.

Would anyone out there be able to help me?

For the chat command aspect you should look into the TextChatService, or more specifically the TextChatCommand instance. When it comes to creating the zone itself you can look into the Instance base class for managing instances in scripts. It has a .new() method that lets you create parts. To update the parts position you could consider taking a look at the RunService. It features multiple methods and events for time-management that enable you to update your zones position every frame.

A few examples that might be helpful:

Creating a part:

local part = Instance.new("part") --Can be used to create a new part
local part.Parent = workspace 

Running a function every frame:

local RunService = game:GetService("RunService")

--I recommend taking a look at what these events are used for in the RunServices documentation linked above.
RunService.Heartbeat:Connect(function() 
    --Code to update your parts position could go here
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.