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

How do I make a GUI visible from clicking on a cloned model?

So I have a placement system that clones a model in ReplicatedStorage that you can then place. I would like when the player hovers over the item and clicks, a GUI appears.

I have this LocalScript in StarterGui.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local edit = script.Parent:WaitForChild("Edit")

mouse.Button1Down:connect(function()
if mouse.Target ~= nil and mouse.Target.Name == "Base" then
	edit.Visible = true
	end
end)

When I just have the model in Workspace without the clone/placement, it works fine. But once I clone the model, it doesn't work.

I'm not entirely sure how to fix this... any help will be appreciated.

5 comments

0

This code is generic enough that I can't see any reason why it wouldn't work on a Clone of the original 'Base' model. Are you sure 'Base' is getting cloned as well?

0

Yes, it is being cloned. It only happens after it's placed, so I was thinking when your moving the model to place using the mouse, it is not properly being disconnected or something. Is there a way to further check this?

0

If it's in the workspace, it's in the workspace. You can try various print statements inside your LocalScript to see what mouse.Target is, or use the variable watch pane in Studio to a similar effect.

0

Alright, I found the issue. It appears there was a part on the surface the model was being placed on that was causing it. Thanks anyway for your quick responses!

0

Where is the "Edit"? I think that It can't find the child as it's in StarterGui when you told the script to find it in game.

1 answer

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local edit = script.Parent:WaitForChild("Edit")

MouseButton1Down:connect(function() -- You made an error, this was 'mouse.Button1down' when it should have been as-is.
if mouse.Target ~= nil and mouse.Target.Name == "Base" then
    edit.Visible = true -- You should either use a frame, or UDIM2.

    end

end)

1 comment

0
  1. Your first statement is incorrect; his original code for line 5 was correct. 2. All GUI objects, except ScreenGuis, have a Visible property, so that's not his problem either. 3. UDim2 changes the properties of the GUI (Position and Size), so how would that have the GUI turn "invisible?"

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