#how to make cylinder spawn when mouse clicks ground

1 messages · Page 1 of 1 (latest)

fallen light
#

it's like this

#

i want it to be like this

#

everytime i press

spare stone
#

just make it thinner

#

i dont really get ur issue

fallen light
fallen light
#

local script in StarterPlayerScripts: `local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local mouse = player:GetMouse()
local plantEvent = ReplicatedStorage:WaitForChild("PlantRequest")

mouse.Button1Down:Connect(function()
local target = mouse.Target

if target and target.Name == "SoilBase" then
    local pos = mouse.Hit.Position
    local soilY = target.Position.Y + (target.Size.Y / 2)  -- top surface of soil
    plantEvent:FireServer(pos, soilY)
end

end)
`

#

script in Server Script: `local ReplicatedStorage = game:GetService("ReplicatedStorage")
local plantEvent = ReplicatedStorage:WaitForChild("PlantRequest")
local patchTemplate = ReplicatedStorage:WaitForChild("PlantPatch")

-- Minimum distance between patches
local MIN_DISTANCE = 4

local function isTooClose(position)
for _, patch in pairs(workspace:GetChildren()) do
if patch.Name == "PlantPatch" then
local dist = (patch.Position - position).Magnitude
if dist < MIN_DISTANCE then
return true
end
end
end
return false
end

plantEvent.OnServerEvent:Connect(function(player, position, soilY)
if isTooClose(position) then
print("Too close! Pick another spot.")
return
end

local newPatch = patchTemplate:Clone()

-- Perfect placement: sits exactly on top of soil
newPatch.Position = Vector3.new(
    position.X,
    soilY + (newPatch.Size.Y / 2),
    position.Z
)

-- Correct flat orientation for the cylinder
newPatch.Orientation = Vector3.new(0, 90, 90)

newPatch.Parent = workspace

end)
`

fallen light
#

i've to sleep now

#

if u have solution please write

coarse forum
#
--Script (StarterPlayerScripts)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local mouse = player:GetMouse()
local plantEvent = ReplicatedStorage:WaitForChild("PlantRequest")

mouse.Button1Down:Connect(function()
    local target = mouse.Target

    if target and target.Name == "SoilBase" then
        local pos = mouse.Hit.Position
        local soilY = target.Position.Y + (target.Size.Y / 2)  -- top surface of soil
        plantEvent:FireServer(pos, soilY)
    end
end)


--Script (ServerScriptService)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local plantEvent = ReplicatedStorage:WaitForChild("PlantRequest")
local patchTemplate = ReplicatedStorage:WaitForChild("PlantPatch")

-- Minimum distance between patches
local MIN_DISTANCE = 4

local function isTooClose(position)
    for _, patch in pairs(workspace:GetChildren()) do
        if patch.Name == "PlantPatch" then
            local dist = (patch.Position - position).Magnitude
            if dist < MIN_DISTANCE then
                return true
            end
        end
    end
    return false
end

plantEvent.OnServerEvent:Connect(function(player, position, soilY)
    if isTooClose(position) then
        print("Too close! Pick another spot.")
        return
    end

    local newPatch = patchTemplate:Clone()

    -- Perfect placement: sits exactly on top of soil
    newPatch.Position = Vector3.new(
    position.X, soilY + (newPatch.Size.Y / 2), position.Z)

    -- Correct flat orientation for the cylinder
    newPatch.Orientation = Vector3.new(0, 90, 90)
    newPatch.Parent = workspace
end)

had a hard time reading that sorry

#

is anything printing when you try to plant? or no

dusk marlin
#

lol grow a garden clone and that looks like ai. if you struggling with this you gonna have a hell of a time when you get to saving/loading these things and doing the offline growing thing. ai doesn't understand what you mean by "perfect placement" and "sit exactly on top of the soil" no matter how many times you try to ask it hehe https://create.roblox.com/docs/tutorials/fundamentals/coding-1/coding-fundamentals

Teaches the basics of coding with Luau.

coarse forum
eternal zodiac
#

@fallen light When ur done with grow a garden modded send that server link fr

fallen light
eternal zodiac
#

Than still send the link once done

coarse forum
#

either way that's just overfarmed

fallen light
#

oh

#

then i need completely new idea-

coarse forum
#

😭

#

well if you want to make a clone of a game im not stopping you

#

but original ideas are better

fallen light
#

okay

#

wait how did u make that writing 😭

coarse forum
#

judging by the images it's not anexact copy of both so you're good

#

*text*

fallen light
#

hi

#

oh

#

thanks

coarse forum
#

there's a lot more stuff you can do

fallen light
#

im more like maps, gui,ui, animations etc

coarse forum
#

i was referring to font stuff
*text* makes italics **text** makes bold ||text|| adds spoiler [text](link) changes link text __text__ makes underline ~~text~~ strikes through

fallen light
#

hi

#

oh