I am trying to make this GUI open when touching a brick/part and it seems not to work. Any help?
script.Parent.Touched:connect(function()
game.StarterGui.Radio1.Enabled = true
end)
I am trying to make this GUI open when touching a brick/part and it seems not to work. Any help?
script.Parent.Touched:connect(function()
game.StarterGui.Radio1.Enabled = true
end)
It's because you're defining the gui on StarterGui, wich replicates it to the player in PlayerGui, so what you should do is create a localscript in the StarterGui and the GUI inside the localscript, a remote event inside replicatedstorage and write this script in the localscript:
local gui = script.YouGuiName
local brickTouchedEvent = game.ReplicatedStorage.YouRemoteEventNameHere
brickTouchedEvent.OnClientEvent:Connect(function()
gui.Enabled = true
end)
Then place a normal script inside your part to be touched and write this script:
local brick = script.Parent
local brickTouchedEvent = game.ReplicatedStorage.YourRemoteEventNameHere
local debounce = false
brick.Touched:Connect(function(hit)
if not debounce then
debounce = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
brickTouchedEvent:FireClient(player)
wait(4)
debounce = false
end
end)
I hope this helps!
Hello there! StarterGui is basically like StarterPack, except for GUIs. If you edit a GUI in StarterGui, it only will show up if a new player joins. To fix this, you can do the following:
script.Parent.Touched:connect(function()
game.Players.LocalPlayer.PlayerGui.Radio1.Enabled = true
end)
If it's a local script, it will work.
Hope this helped!
mean
Just because someone else answered after you doesn't mean they copied you or stole from you, they could have just posted the post and your answer wasn't there intill he clicked answer (by refreshing the answers).
Before putting this in, make sure you put the GUI in ReplicatedStorage and the script is a LocalScript
local RP = game:GetService("ReplicatedStorage")
local gui = RP.Radio1
script.Parent.Touched:Connect(function()
gui.Parent = game.Players.LocalPlayer.PlayerGui
gui.Visible = true
end)
Comment on this answer if it doesn't work, and if you want anything else implemented into this script (if you walk off the brick it gets rid of the GUI, the GUI fade-in, etc.)
Your welcome if it worked,
Narwhal
This is unnessary, you could just change the enabled value (if it was a gui) or visible (if it was a frame).
Im sorry I didn't know it was in the starter gui. Plus, this is the way I do it. Also, I forgot it was Enabled for a gui. In my early days of developing, I was making a model greatly depending on guis. I didn't understand the gui's properties, so in the script I made the gui Enabled and tried to make it visible using the Visible property even though there's no such thing. That threw me off.
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
Beat me to it.
Ty!
Both beat me to it.
np