Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script won't work and nothing is showing in the output! I tried everything I know. Help?

Asked by 4 years ago
Edited by Ziffixture 4 years ago

I am trying this script out but it won't work. I looked at the output and not showing there. But the goal of the script is not working.... Here is the script:

script.Parent.MouseClick:Connect(function()
    game.StarterGui.NpcChat.Background.Visible = true
end)

Key: NpcChat = ScreenGui Background = Frame Parent = a dummy r6 model

(The goal of this script is that when you click the Npc's torso, a frame appears)

Currently the Background is not visible and I'm really confused... Is there anything I need to change in the StarterGuy? Or is their a error? Please help!

0
I don't get what you're asking... when you click the NPC's torso a frame appears?, also if you're posting scripts please use codeblocks. Auxatier 59 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

I think what you could do is put a click detector in the torso and do a .MouseClicked event, then just set the frame Visiblity = true if it has been clicked.

0
MouseClick is already being called from script.Parent, which shows the existing presence of a ClickDetector already. Ziffixture 6913 — 4y
Ad
Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

StarterGui is not the authentic storage location of the local UI. Each Player has their own GUI container called PlayerGui. Upon joining, all the contents of StarterGui are actively moved into said container to effectively give the Player their own UI. This is done because if all GUI Objects get stored and read from one place, such a StarterGui, everyone would see the same GUI appear, and would loose the personal use of their own screen.

You need to call upon the PlayersPlayerGui` container to actively manage their UI properly.

local ClickDetector = script.Parent

ClickDetector.MouseClick:Connect(function(PlayerClicked)
    PlayerClicked.PlayerGui.NpcChat.Background.Visible = true
end

Answer this question