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)
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)
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?
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)
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.
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.
local player = game:GetService(“Players”)
local UI= game.StarterGui.CraftingSystem
script.Parent.ClickDetector.MouseClick:Connect(function()
if UI.Enabled == false then
UI.Enabled = true