Why Doesn't My Script Work?

Also I just Tested, and this time no error came up, but the obby did not spawn

2 Likes

Hmm so I just did what you said in your 1st message still waiting to test, but when I tested right before, the error was gone, but no obby apeared.

2 Likes

Hmm, can you send an updated screenshot of the explorer tab, as well as the new script?

2 Likes

This is the newest:

Explorererer

local ObbiesFolder = game.ReplicatedStorage:FindFirstChild("Obbies")
local TextBox = script.Parent.Parent.TextBox

ObbyAlreadySpawned = false
local obby = nil
script.Parent.MouseButton1Down:connect(function ()
	if obby then
		obby:Destroy()
	end

	Obby = ObbiesFolder[TextBox.Text]:Clone() --In this line in studio, Obby as a red line under it.

	Obby.Parent = game.StarterGui.SurfaceGui
	ObbyAlreadySpawned = true
end)

2 Likes

I see. Just change the third to last line to Obby.Parent = workspace and you should be good to go. :+1: (Objects are only visible if they are inside the workspace)

1 Like

Thank you so much! It worked, now I can just use the same system for all the other obbies!

2 Likes

Found an improvement that can be made in case it doesn’t find an obby with the given name.

local ObbiesFolder = game.ReplicatedStorage:FindFirstChild("Obbies")
local TextBox = script.Parent.Parent.TextBox

ObbyAlreadySpawned = false
local Obby = nil
script.Parent.MouseButton1Down:connect(function ()
	if Obby then
		Obby:Destroy()
	end

	SelectedObby = ObbiesFolder:FindFirstChild(TextBox.Text) 

        if SelectedObby then
        Obby = SelectedObby:Clone()
	        Obby.Parent = game.StarterGui.SurfaceGui
	        ObbyAlreadySpawned = true
        end
end)
2 Likes

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