I want to try and make a smooth building block mechanic tool; Like in Roblox skywars.
I have a issue trying to make it so you can easily bridge at ease, like this. Screen Recording (5-27-2021 9-03-46 PM).wmv (1.8 MB)
But it’s been going like this… rec.WMV (6.1 MB)
I’ve been trying local prefixes to get a 12 x 12 block (Named Bridge) to place down below the dirt (Named FakePart), and it’s very hard to make a clone of Bridge below the dirt. Can anyone tell me how to fix this script so two locals can conjoint?
game.ReplicatedStorage.Events.PlaceBlock.OnServerEvent:connect(function(plyr, ncf, target)
if player then -- Dont worry about "blocks", its just a variable.
if player.Name == plyr.Name then
if blocks then
if blocks.Value > 0 then
if target.Parent then
blocks.Value = blocks.Value - 1
script.Parent.Handle.Place:Play()
script.Parent.Displayer.SGui.Detail.Text = blocks.Value
local np = game.ReplicatedStorage.FakePart:Clone() -- This part are what I'm really worried about
np.CanCollide = true -- These parts are what I'm worried about
np.CFrame = ncf -- These parts are what I'm worried about
np.Name = 'Dirt' -- These parts are what I'm worried about
local pskin = game.ReplicatedStorage.PlayerSkins:FindFirstChild(plyr.Name)
if pskin then
if pskin.Value ~= "Default" then
for _,v in pairs (np:GetChildren()) do
if v:IsA("Texture") then
v.Texture = "rbxassetid://" .. pskin.Value
end
end
end
end
if target.Parent.Name ~= 'WoodTrunk' and target.Parent.Name ~= 'GrassBlock' and target.Parent.Name ~= 'BronzeOre' and target.Parent.Name ~= 'GoldOre' and target.Parent.Name ~= 'DiamondOre' then
np.Parent = target.Parent
else
np.Parent = target.Parent.Parent
end
game.Debris:AddItem(np, 200)
end
end
end
end
end
end)
So can anyone help me to add another local to the area where it says
So basically, How can i have a local do 2 actions?
By in local, i mean local Example = game.Workspace.Example.Example.
I want a local To do 2 actions. Need more explanation? Ask!
Okay! So what i want is, how can i have a local do 2 actions?
By in local, i mean like in a script local Example = game.Workspace.Example.Example.
I want a local To do 2 actions. Need more explanation? Ask!
Use the mouse’s hit cframe and math to get the edge of the block(mouse.target) the cursor is nearest too, then check if theres an open space in that direction next to it and if there is, place the block
Basically what you need like lets say you are in a while loop and you want to execute some code whenever a value is set to true but you cant so that cuz you are in a while loop right? To do that we use coroutines. Lemme give you an example.
Btw im on mobile rn so it will take sometime for me to write.
local val = false
local function CorFunc()
While true do
wait(2)
if val == true then
--code the stuff thats gonna happen while the while loop goes on.
end
end
end
local cor = coroutine.create(CorFunc)
coroutine.resume(cor)
while true do
-- other code that goes on
end
Note: You should not use this as i wrote this for example, i’d say research and learn coroutines and then look at this exapmle
I dont know how your block system works but if it has a grid you could do targetIndex + 1 in the direction but if thats not how your system works then you can raycast starting from the target block origin into the direction you want with the length of the ray as (block size/2) + 1