I made a local script
-- Get Player
local Player = game.Players.LocalPlayer
-- MainThings
local TileGrid = workspace.Build1.Tiles
local Mouse = Player:GetMouse()
local TargetedBlock
-- Border
local Border = Instance.new("SelectionBox")
Border.Parent = workspace
Border.LineThickness = .01
Border.Color3 = Color3.new(255,255,255)
-- Services
local RunService = game:GetService("RunService")
-- Block Data Handler
local BlockSize = Vector3.new(3,3,3)
local BlockMaterial = Enum.Material.Wood
local BlockColor = BrickColor.White()
-- Events
local PlaceBlock = game.ReplicatedStorage.PlaceBlock
local RemoveBlock = game.ReplicatedStorage.RemoveBlock
-- Make Border on Targeted Block
RunService.Heartbeat:Connect(function()
local Target = Mouse.Target
if Target then
if Target.Parent == TileGrid then
Border.Adornee = Target
TargetedBlock = Target
else
Border.Adornee = nil
TargetedBlock = nil
end
end
end)
-- Create Block on Click
Mouse.Button1Down:Connect(function()
if TargetedBlock then
if Mouse.TargetSurface == Enum.NormalId.Top then
print("Attempt to place block")
PlaceBlock:InvokeServer(Player, BlockMaterial, BlockColor, (TargetedBlock.Position + Vector3.new(0,3,0)))
end
end
end)
Earlier I made a function inside the script so that it will place a block, but after that I realised it was only affecting the client so I made Remote a Remote Function.
here is the script that makes the remote function work
local Events = script.Parent
Events.PlaceBlock.OnServerInvoke:Connect(function(Player, Mat, Color, Position)
print("Block Is Placed")
local NewBlock = Instance.new("Part")
NewBlock.BrickColor = Color
NewBlock.Material = Mat
NewBlock.Size = Vector3.new(3,3,3)
NewBlock.Position = Position
NewBlock.Parent = workspace.Build1
NewBlock.Anchored = true
end)
After I tried this, it wasn't working... The local script is doing its part but when it Invokes the script is not printing the message i made it print

2 comments
Thanks! All I had to do was to put the Script in to the ServerScriptService
No Problem :)