Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My "objectives" script isnt working, but the print is?

So i have an island, and in that island i have a big clear brick that has a script thaht is supposed to change guis and its not switching, but the "print" part in the script is working. Any help?

And any suggestions to make the script go off once? Because everytime the player moves it prints like 20 "youve entered the island"

script;

local islandtext = game.StarterGui.Findisland.TextLabel
local boattext = game.StarterGui.Findboat.TextLabel




script.Parent.Touched:connect(function(hit)
 if hit.Parent:FindFirstChild("Humanoid") then
	islandtext.Visible = false
	wait (2)
	boattext.Visible = true
	print "youve entered the island"
 end
end)

1 answer

You have quite a few issues here that need fixing before your visibility script will work.

1.) For making User Interface objects visible when a part is touched, you have to send a signal through a RemoteEvent that tells a local script to call a function. That function would then make the text labels invisible or visible based on a parameter you might give it.

For the following code block to work, you need to follow these steps. 1 - Put a RemoteEvent in ReplicatedStorage named 'SetVisible' 2 - Make a local script inside the ScreenGui that is inside the StarterGui 3 - Put the following inside the local script.

--Local Script

local TextLabel1 = script.Parent.TextLabel1
local TextLabel2 = script.Parent.TextLabel2
--Name your text labels accordingly

local RemoteEvent = game.ReplicatedStorage.

local function SetVisiblity(val)
	if val == true then
		TextLabel1.Visible = true
		TextLabel2.Visible = true
	else
		TextLabel1.Visible = false
		TextLabel2.Visible = false
	end
end

RemoteEvent.OnClientEvent:Connect(function(val)
	SetVisibility(val)
end)

This will make it so that when you call the RemoteEvent (aka RemoteEvent:FireClient(Player, true)) it will set the text label to the bool value you give it.

2.) You are trying to make the objects inside StarterGui visible, which isn't the player's actual menu. The player's actual menu is within the player itself. It's name is PlayerGui. However you can't access anything inside of the player's GUI from the server side, so you need to have a local script inside the StarterGui or ScreenGui to control everything.

1 comment

0

in line 9 i get the error saying "Error: (9,1) Expected identifier, got 'local'", and when i delete local it says the same thing but instead of local its "function"

This discussion is preserved as it was. New answers, comments, and votes are closed.