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

Anything wrong with this script? It won't spawn in a GUI like it should be doing

Asked by 5 years ago
Edited 5 years ago
function onClick(Player)
    screen = game.ServerStorage.Room1
    clone = screen:Clone()
    clone.Parent = Player.PlayerGui
    wait(1)
    clone:Destroy()
end

script.Parent.ClickDetector.MouseClick:Connect(onClick)

I don't get any errors whatsoever, and I was using it earlier and it worked perfectly fine. I have no idea what happened and why it no longer works. I even set everything back to the way it was when it was working and it still didn't work.

0
edit your question to use codeblock so we can read it wittyusername65 0 — 5y
0
is this script in a localscript? if so, localscrpts cant access serverstorage. wittyusername65 0 — 5y
0
no, it is just a normal script AkihitoOkami 0 — 5y
0
is the script disabled User#23365 30 — 5y
0
no AkihitoOkami 0 — 5y

1 answer

Log in to vote
0
Answered by
moo1210 587 Moderation Voter
5 years ago
Edited 5 years ago

There are two things wrong with it. First thing is that the values like clone = screen:Clone() aren't working because there is no local. The 2nd thing is after 1 second it destroys the clone it just made. So It would take on the client for 1 second and then get removed. This is the fixed code.

function onClick(Player)
    local screen = game.ServerStorage.Room1
    local clone = screen:Clone()
    clone.Parent = Player.PlayerGui
end

script.Parent.ClickDetector.MouseClick:Connect(onClick)

Did my answer fix the issue? Please accept my answer it will give us both rep. Was my answer good? Upvote it as you wish, or well even downvote but that takes away rep :(

0
nope, that didn't work. AkihitoOkami 0 — 5y
Ad

Answer this question