Feedback on part spawning script

After a tiny bit of looking into videos tutorials, I did my first practice script ever without any help & I’m wondering how I can improve with writing this code because I feel like there’s probably way easier ways to do something like this.

On a side note, Is there any suggestions as to what I should focus on learning first as a beginning scripter?

local function PointSpawner()
	while true do 
		wait(0.5)
		local NewP = Instance.new("Part")
		local Bil = Instance.new("BillboardGui")
		local tex = Instance.new("TextLabel")
		local vel = Vector3.new(0,100,0)
		Bil.Parent = NewP
		Bil.Size = UDim2.new(0,100,0,100)
		tex.Size = UDim2.new(0,100,0,100)
		tex.Parent = Bil
		tex.Text = ("Test")
		NewP.Position = Vector3.new(0,10,0)
		NewP.Size = Vector3.new(0.1,0.1,0.1)
		NewP.Anchored = false
		NewP.Parent = workspace
		NewP.Velocity = vel
		
		print ("Part Spawned")
	end
end

if game.Players.PlayerAdded then
	wait(5)
	PointSpawner()
end

Rather than adding a BillBoardGui, TextLabel, etc. to the part in the script, it would be more efficient to create a part in studio and place those things inside of it. Then customize those things to your liking in the properties window. You can then simply place the part into ReplicatedStorage.

Your new script would be:

local part = game:GetService("ReplicatedStorage"):WaitForChild("myPart")

local functon PointSpawner()
    while true do
    wait(0.5)
    local newPart = part:Clone()
    newPart.Parent = workspace
    newPart.Name = "NewPart"
end
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.