Hello. I made a small project and I want to share it with other people. It is an improved version of my free model made in 2021. The general concept of the open sourced project is explained in the title. Players are allowed to place blocks (snapped to grid) and destroy these blocks. Here are all features of this project:
Blocks placement system;
Blocks destroying system;
Anti-cheat system (only for the tools in the experience);
Customizable building tools (I explained it below).
Here are three tools (all of these can be duplicated to suit Your needs):
The tools have few customizable attributes:
CanFloat - definies if a block can be a part of a “floating island”. This block can make other blocks with CanFloat set to false float. I showed this mechanic below in the video,
Color - definies the color of placed blocks;
IsColorRandom - if set to true, it randomizes colors for each placed block (and overwrites Color attribute);
Material - definies material of placed blocks;
MaxDistance - this attribute is common to the building tools and to the destroying tool. It definies the maximum distance of placing and destroying blocks.
The attributes can be dynamically changed by scripts in-game and the tools will adjust to the changes made in the attributes.
The video of the tools in action is here: robloxapp-20230407-1753539.wmv (5.5 MB)
Here is a link to the project, feel free to download it:
Make sure that IsColorRandom attribute of the building tool is set to false. Next choose a color by changing Color attribute of the tool to a desired color. As I said, it is possible to change the attributes of the tool while the game is running by using a server script:
For example this means that for example the tool will place green blocks and 60 seconds later it will place yellow blocks. To change the tool while the game is running by using a script, you need to do something like this:
local tool -- Reference to the tool should be here
task.wait(10)
tool:SetAttribute("Color", Color3.fromRGB(255, 0, 0))
Everytime i try to change the attribute value, it always stays the same color
so bascially i used a color palette to send a color to a value in the player’s folder. Then i use a script inside the tool which gets the color’s value. Then it changes it’s attribute. It does change the attribute value But, it doesnt change it for the block’s color.
My script:
local player = game:GetService("Players").LocalPlayer
local blockcolor = player.Color.Color
script.Parent:SetAttribute("Color", blockcolor.Value)
Okay, I know what is the issue. The server downloads the color to use but you are changing the color by using a local script so the server can’t see the color changes. Use a remote event to change the color attribute on server side.
To demonstrate it I made a system where player can change color to green by pressing Q and player can change color to blue by pressing E. Read the steps to figure this out.
To the tool insert RemoteEvent called “ChangeColor”, a server script called “AcceptColors” and a local script called “RequestColors”. The result of this step should look like this (I marked in red instances made in this step):
Modify the source code of the RequestColors local script so it looks like this:
local green, blue = Color3.fromRGB(0, 255, 0), Color3.fromRGB(0, 0, 255)
local changeColor = script.Parent:WaitForChild("ChangeColor")
local begin = Enum.UserInputState.Begin
game:GetService("ContextActionService"):BindAction("To green", function(actionName, inputState, inputObject)
if inputState == begin then
changeColor:FireServer(green)
end
end, false, Enum.KeyCode.Q)
game:GetService("ContextActionService"):BindAction("To blue", function(actionName, inputState, inputObject)
if inputState == begin then
changeColor:FireServer(blue)
end
end, false, Enum.KeyCode.E)
Repeat the step 2 but with different code and for AcceptColors server script:
local tool = script.Parent
tool.ChangeColor.OnServerEvent:Connect(function(player, requestedColor)
tool:SetAttribute("Color", requestedColor)
end)
Yes but it will appear only for the client who set the colors. By saying by that I mean that for the client the blocks will appear let’s say green but for others the colors of these blocks will be still white (previous color).
EDIT: If it was possible to change on client for others it would mean that the game would be very vunerable to exploits.
Hello, can you try and demonstrate a script that only changes the colors of the client instead of the server, like if Player one has red selected, and player 2 has blue. P1 placed a block, its red. P2 placed a block, its blue.
if possible i can share you an uncopylocked version of the game im working on and can you see how it can be client sided while also having a server sided block placement
It does not seem like a problem. You can consider sending your code where the change mentioned above should be implemented but its up to you how we will do it.
The thing that is wrong is that if a one player picks a color, it is the server’s color. i want to make it so that if a player picks a color, thats their color.