yes but if i want to type that into a local script i would say
local playerName = game.Players.LocalPlayer.Name
newBlock.Parent = game.Workspace.PlayerFolders:FindFirstChild(playerName)`
even thought my script is a SSS Script so how would i do that in a SSS Script
From the client you use a remote event or function and fire it so the server gets the data of where the block needs to be placed + the player’s instance as the first argument
Thanks thats a good way to do it also but im trying to see if i can find a simpler way lol
i already have the building system and all that i just need to change the parent of the placed building from workspace to the player personal folder
Sorry to say but that’s probably one of the easiest ways I can think, you will need to communicate with the server or else all the objects will only be on the client, which means they will be not existant on the server.
For the communication with the server you can use the RemoteEvents.
send your building system scripts
First Script
local snap = 3
game.ReplicatedStorage.PlacingSystem:WaitForChild("PlaceBlockRE").OnServerEvent:Connect(function(plr, blockType, target, targetSurface, removeOrPlace)
if removeOrPlace == "placing" then
local position
if targetSurface == Enum.NormalId.Top then
position = target.Position + Vector3.new(0, snap, 0)
elseif targetSurface == Enum.NormalId.Bottom then
position = target.Position - Vector3.new(0, snap, 0)
elseif targetSurface == Enum.NormalId.Left then
position = target.Position - Vector3.new(snap, 0, 0)
elseif targetSurface == Enum.NormalId.Right then
position = target.Position + Vector3.new(snap, 0, 0)
elseif targetSurface == Enum.NormalId.Front then
position = target.Position - Vector3.new(0, 0, snap)
elseif targetSurface == Enum.NormalId.Back then
position = target.Position + Vector3.new(0, 0, snap)
end
local blockInPos
for i, d in pairs(workspace:GetDescendants()) do
if d:IsA("BasePart") and d.Position == position then blockInPos = true end
end
if not blockInPos and position then
local newBlock = blockType:Clone()
newBlock.Size = Vector3.new(snap, snap, snap)
newBlock.Anchored = true
newBlock.Position = position
local playerName = game.Players.PlayerAdded:Connect()
newBlock.Parent = game.Workspace:FindFirstChild(playerName.Name)
game.ReplicatedStorage.PlacingSystem.PlayPlacingSoundRE:FireClient(plr)
end
-- Checks if the block is a Terrain
elseif removeOrPlace == "removing" then
if target and target:FindFirstChild("Terrain") then
workspace.Terrain:FillBlock(target.CFrame, target.Size, Enum.Material.Air)
game.ReplicatedStorage.PlacingSystem.PlayRemovingSoundRE:FireClient(plr)
target:Destroy()
-- Checks if the block is a Solid
elseif target and target:FindFirstChild("Placeable") then
target:Destroy()
game.ReplicatedStorage.PlacingSystem.PlayRemovingSoundRE:FireClient(plr)
end
end
end)
local gridX, gridZ = 100, 100
for x = 1, gridX do
for z = 1, gridZ do
local block = game.ReplicatedStorage.AdminBlock:Clone()
block.Size = Vector3.new(snap, snap, snap)
block.Anchored = true
block.Position = Vector3.new(snap * x, snap, snap * z)
block.Parent = workspace
end
end
Second Local Script
local snap = 3
--Blocks
local blocks = game.ReplicatedStorage:WaitForChild("Blocks")
local placeRE = game.ReplicatedStorage.PlacingSystem:WaitForChild("PlaceBlockRE")
local chosenBlock = blocks:GetChildren()[1]
for i, block in pairs(blocks:GetChildren()) do
local clonedTemplate = script:WaitForChild("BlockButton"):Clone()
local name = block.Name
clonedTemplate.BlockName.Text = name
local blockClone = block:Clone()
blockClone.Size = Vector3.new(snap, snap, snap)
blockClone.Parent = clonedTemplate.BlockImage
local cam = Instance.new("Camera")
clonedTemplate.BlockImage.CurrentCamera = cam
cam.Parent = clonedTemplate.BlockImage
cam.CFrame = CFrame.new(blockClone.Position + Vector3.new(3.3, 3.3, 3.3), blockClone.Position)
clonedTemplate.Parent = script.Parent
clonedTemplate.MouseButton1Click:Connect(function()
chosenBlock = blocks[name]
end)
end
--Terrains
local terrains = game.ReplicatedStorage:WaitForChild("Terrains")
local placeRE = game.ReplicatedStorage.PlacingSystem:WaitForChild("PlaceBlockRE")
local chosenTerrain = terrains:GetChildren()[1]
for i, terrain in pairs(terrains:GetChildren()) do
local clonedTemplate = script:WaitForChild("BlockButton"):Clone()
local name = terrain.Name
clonedTemplate.BlockName.Text = name
local terrainClone = terrain:Clone()
terrainClone.Size = Vector3.new(snap, snap, snap)
terrainClone.Parent = clonedTemplate.BlockImage
local cam = Instance.new("Camera")
clonedTemplate.BlockImage.CurrentCamera = cam
cam.Parent = clonedTemplate.BlockImage
cam.CFrame = CFrame.new(terrainClone.Position + Vector3.new(3.3, 3.3, 3.3), terrainClone.Position)
clonedTemplate.Parent = script.Parent.Parent.TerrainList
clonedTemplate.MouseButton1Click:Connect(function()
chosenBlock = terrains[name]
end)
end
local mouse = game.Players.LocalPlayer:GetMouse()
local selectingBox = Instance.new("SelectionBox", workspace)
game:GetService("RunService").RenderStepped:Connect(function()
local target = mouse.Target
if target then
if target:FindFirstChild("Placeable") then
selectingBox.Adornee = target
else
selectingBox.Adornee = nil
end
end
end)
local isRemoving = false
mouse.KeyDown:Connect(function(key)
if key == "x" then
isRemoving = true
end
end)
mouse.KeyUp:Connect(function(key)
if key == "x" then
isRemoving = false
end
end)
local isPlacing = false
mouse.Button1Down:Connect(function()
isPlacing = true
end)
mouse.Button1Up:Connect(function()
isPlacing = false
end)
game.ReplicatedStorage.PlacingSystem.PlayRemovingSoundRE.OnClientEvent:Connect(function()
script.RemovingSound:Play()
end)
game.ReplicatedStorage.PlacingSystem.PlayPlacingSoundRE.OnClientEvent:Connect(function()
script.PlacingSound:Play()
end)
local blockCooldown = 0.25
while wait() do
local target = mouse.Target
if target and target:FindFirstChild("Placeable") then
if isPlacing then
placeRE:FireServer(chosenBlock, target, mouse.TargetSurface, "placing")
wait(blockCooldown)
elseif isRemoving then
placeRE:FireServer(nil, target, nil, "removing")
wait(blockCooldown)
end
end
end
plr is right here…
so…
and how do i define the player
what are you talking about, you should do some reading and come back, the information has been provided… figure it out
Remote Functions and Events (roblox.com)
Roblox Client-Server Model
The player is already defined, you can just use the variable plr
. As I said the first argument of RemoteEvent is the player, which is what you are looking for.
ah lol i already defined it i think idk its been 1 week since i wrote this script
okay got it i will try that thank you both i will mark it as a solution if it works
ik lol im dumb
This is perfect its working perfectly and all the blocks are being placed organizedly in the player folders thank you so much both of y’all @kylerzong @Isaque232
Np! Make sure to mark the solution in your 2 topics so people know It’s already done
Yeah sorry i couldn’t mark you as a solution but i will mark you on the other post