So I’ve been developing a RP Game. I’ve been trying to link a Click Detector to activate a GUI. I want a Car Spawn GUI to appear when a block is clicked.
This is the Current script I have for activating it but it won’t work:
local click = script.Parent.Parent.Parent.Workspace.Spawn:WaitForChild("ClickDetector")
local frame = script.Parent:WaitForChild("CarSpawner")
click.MouseButton1Click:Connect(function()
frame.Visible = true
end)
Could you be more specific? More context?
Where are these scripts? Is it a server or local scripts?
Where is the GUI placed?
What actually doesn’t work?
Please do follow the guidelines and this thread does not belong here, it should be in #development-support:scripting-support
If you want a GUI to appear when you click a part then you’ll need to use a ClickDetector. This goes under your basepart. To interact with it in your case, you’ll want to use the .MouseClick event. Then you can do what you want to do.
This method is fine when you are using a clickdetector as described above, but do not use this in other scripts!
It could yield whole server-scripts if the client does not have the PlayerGui for any reason, or deleted it.
I would recommend using a RemoteEvent that sends the signal to the player to display the UI.
--[[
Open Position: {0.25, 0},{0.398, 0}
Close Position: {0.25, 0},{-0.25, 0}
--]]
local Frame = script.Parent
local Open = false
local Debounce = false
function ToggleTween()
if Open == false and Debounce == false then
Debounce = true
Frame:TweenPosition(UDim2.new(0.25, 0,0.398, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Bounce,0.75,false)
wait(1)
Open = true
Debounce = false
elseif
Open == true and Debounce == false then
Debounce = true
Frame:TweenPosition(UDim2.new(0.25, 0,-0.25, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Bounce, 0.75, false)
wait(1)
Open = false
Debounce = false
end
end
-- Now use ToggleTween() to toggle the GUI everytime you want.
while wait(3) do
ToggleTween()
end
You can use any other method to toggle it with the ToggleTween() function. The while wait(3) do is to test it. Here is the GUI example: GUI.rbxm (2.4 KB)
Can I please remind that spoon feeding code isn’t what these categories are made for. Its intended to support other users into getting to the goal they intend to.