Hello! I need help, I’m new to coding I want to make a part spawn and make it change it’s material, but it would just have the normal Roblox studs, pls help
local DropperPartsFolder = script.Parent.Parent.Parent.DropperParts
while wait(5) do
local NewPart = Instance.new(“Part”,DropperPartsFolder)
NewPart.Position = script.Parent.SpawnPart.Position
NewPart.Size = Vector3.new(1.3, 1.3, 1.3)
local CashValue = Instance.new("NumberValue",NewPart)
CashValue.Value = 1
CashValue.Name = "CashValue"
end
Hi! It’s really nice to see you taking an interest in coding.
I think what you’re looking for is to spawn a new part and change its material afterward. That’s simple enough to do, let me show you!
local part = Instance.new("Part")
part.Parent = game.Workspace
This quick code snippet right here will go ahead and spawn a new part into your workspace. Now let’s go ahead and change the material!:
local part = Instance.new("Part")
part.Parent = game.Workspace
part.Material = Enum.Material.Grass
The above code snippet will spawn in a new part to your workspace, and change its material to “grass”. As you probably noticed, it’s using “Enum” which is likely something you haven’t run into yet. For now, all you need to know is that Enum makes it easy to select built in items from Roblox’s framework.
This technically answers your question, but I’ll leave you with a suggestion that you read, read, read and read some more.
https://developer.roblox.com/en-us/api-reference/class/Part
The Roblox documentation is EXTREMELY helpful if you learn to use it. The above article discusses “parts” and what and how you can change them.
Good luck, and have fun!
3 Likes
Thx! I will do this right now
It works fine now thank you so much!
Any time, glad I could be of service.
1 Like