Am trying to make a game where you have a lawnmower and must use it to mow the grass to gain money. I want to do this with ReplaceMaterial Function. But nothing seems to work. I tried looking every where. Found some that was pretty close to my case. Followed the steps. Didnt work.
Heres my script (On a server script inside a lawnmower model)
local Mower = script.Parent
local part = Mower.MowerPart
local Settings = require(script.Parent.Settings)
local money = Settings.money
local addition = Settings.addition
while task.wait() do
local PointA = Mower.A.Position
local PointB = Mower.B.Position
local min = PointA.Position
local max = PointB.Position
local region = Region3.new(min,max)
region = Region3:ExpandToGrid(4)
workspace.Terrain:ReplaceMaterial(region, 4, Enum.Material.Grass, Enum.Material.LeafyGrass)
end
(The to selected parts are Part A and B. Which are used for the region3)
so it appears that you are calling the PointA and PointB position twice in the variables the first time in
local PointA = Mower.A.Position
local PointB = Mower.B.Position
and the second time in
local min = PointA.Position
local max = PointB.Position
instead you can completely remove the min and max variables and just do it as
local PointA = Mower.A.Position
local PointB = Mower.B.Position
local region = Region3.new(PointA,PointB)
region = Region3:ExpandToGrid(4)
-- Rest of your code here
local Mower = script.Parent
local part = Mower.MowerPart
local Settings = require(script.Parent.Settings)
local money = Settings.money
local addition = Settings.addition
while task.wait() do
local PointA = Mower.A.Position
local PointB = Mower.B.Position
local region = Region3.new(PointA,PointB)
region = Region3:ExpandToGrid(4)
workspace.Terrain:ReplaceMaterial(region, 4, Enum.Material.Grass, Enum.Material.LeafyGrass)
end
I removed the region = Region3:ExpandToGrid(4) and moved one of the points down by 4 studs but still nothing. I tried moving the point lower down (13 studs) But nothing really changed.