UI won't appear

Hello!
I’m working on a crafting system, nevertheless, when I click the part the UI doesn’t appear on my screen!
The script injected into a part is Localscript.

Here is the script:

local player = game:GetService(“Players”)
local frame = player.LocalPlayer.PlayerGui[“Crafting System”].Frame
script.Parent.ClickDetector:Connect(function()
frame.Visible = true
end)

image
image

Can anyone help me?

1 Like

ClickDetector.MouseClick, you can’t connect an instance, also the MouseClick event returns the player who fired the event, so can’t you do this in a regular script?

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	local frame = plr.PlayerGui["Crafting System"].Frame
	frame.Visible = true
end)
3 Likes

Ahhh, It is still not working!

local part = game.Workspace.craftingpart
local clickDetector = script.Parent.ClickDetector

part.clickDetector.MouseClick:Connect(function()
game.Players.LocalPlayer.PlayerGui.["Crafting System"].Frame = visible
end)

Odd, it should work since this is the simplest way to do it. What’s in your crafting part as of now? Did you put the code in the localscript or the regular script as I mentioned?

I have tried both, script and localscript.

Where did you put the script when testing? In the part or the clickdetector? Did you get any errors?

Is the local script in the part? I don’t believe local scripts run inside of parts.

Try this?

local CD = workspace.craftingpart.ClickDetector

CD.MouseClick:Connect(function(plr)
	local frame = plr.PlayerGui["Crafting System"].Frame
	frame.Visible = true
end)
1 Like

LocalScript’s can only run in places that are a descendant of a player, you’ll have to use a serverscript or put this localscript inside starterplayer scripts and change script.Parent with the object.

1 Like

This script does not work, sadly.

Show the explorer for your craftingpart, also are you getting an error or not?

2 Likes

what are u tryin to achieve here?

you want to click a part and make a ui appear is that it?

I am not getting any errors, also, here is the picture.image

Yeah, that’s what I’m aiming for

Change your code to this:

local clickDetector = script.Parent.ClickDetector

clickDetector.MouseClick:Connect(function(player)
player.PlayerGui["Crafting System"].Frame.Visible = true
end)

Pretty sure this should work.

I’m not a scripter, but I’ll guess.

Alright, so you can see there are 4 frames. I’m not exactly sure but I’d change the Frame’s name and change the script to:

local player = game:GetService(“Players”)
local [NAME] = player.LocalPlayer.PlayerGui[“Crafting System”].[NAME].
script.Parent.ClickDetector:Connect(function()
[NAME].Visible = true
end)

I’m not a scripter apologies if this doesn’t work.

is this enough?

Don’t use .Visible i would use enabled.

local player = game:GetService(“Players”)
local UI= game.StarterGui.CraftingSystem
script.Parent.ClickDetector.MouseClick:Connect(function()
if UI.Enabled == false then
UI.Enabled = true

else

Ui.Enabled = false
end
end)

Positive, that is indeed enough.

in the perspective of making the frame visible
just put the local script into starter gui
find the click detector
and
find the screengui+frame

detector=workspace.clickypart.ClickDetector
detector.MouseClick:Connect(function()
    script.Parent.ScreenGui.Frame.Visible=true
end)