Two days ago I decided I wanted to pick up scripting, and so I’ve been trying to teach myself some stuff via Youtube and Devforum! I was wondering if I could get some feedback on my first scripted piece!
My goal was that when stepping on the grey plot, the entirety of it gains color and material. I think it works nicely, but I was looking for any feedback on script issues, or possibly suggestions for what else could be added!
Also, if anybody knows any excellent discussions or videos regarding beginner scripting resources, I would be most appreciative!
Well, it’s tough to give feedback without having the source code accessible.
I’m not sure if it’s the best source code, or over complicated source code, or mediocre source code. Why not upload the script or paste some key parts as text?
Oh right! Thank you for reminding me! This is my main code:
local Grass = game.Workspace.Grass
local Fence = game.Workspace.Fence
local Bricks = game.Workspace.Bricks
local Roof = game.Workspace.Roof
local House = game.Workspace.HouseMain
local Frame = game.Workspace.Frame
local Door = game.Workspace.Door2
local Window = game.Workspace.Window
local WindowFrame = game.Workspace.WindowFrame
local function Grassy()
Grass.Material = Enum.Material.Grass
Grass.Color = Color3.fromRGB(188, 236, 168)
–
And then I have a separate code that, when a player steps off of the grass plot, activates a similar function, which causes all the parts to turn back to the original color and plastic material. I’ve been looking into way I can maybe mainstream this, as it seems a little messy to have two scripts, are there features that could allow me to achieve these actions under one script?
I’d recommend looking into how Region3 works if you wanna convert this into a full on singular script, as it takes the specific Region of the world space (Or let’s say an invisible part) and you can do something with it (Like changing the colors of the grass plot)
For your first scripted project itself, this is really well done! I congratulate you for this!
But here’s one problem, what if a baseplate touches the part? So this is why you may have to do this:
game.Workspace.Grass.Touched:Connect(function(hit) -- detects if a part is touched and gets what hit it.
local hum = hit.Parent:FindFirstChildWhichIsA("Humanoid") -- searches through the hit's parent and looks if it has a humanoid
if hum then -- if it does have a humanoid
Grassy() -- call the function
end
end)
Ah thank you for this! I initially had some flowers that were to pop out of the ground, but they kept messing up the color/material script because they were touching the plot! This is super helpful, thank you very much!
That’s likely best! I’m still making my way through some beginner scripting series, so maybe once I finish those these newer concepts will make more sense to me!
I’m also learning myself, im also learning from free models and scripter teacher aswell that is cheap for his services. Your doing so good for beinggner as I’m also learner myself so I also read through scripts and look in devform. Well done