Why doesn't this work?

Hey, for some reason this script doesn’t work. And I don’t know why. Can anybody help?


toolgui
If anybody could help me it would be great. Thanks!

On line 5, it should be .Parent, not .Parents

Still doesn’t work. Anything else?

Are there any errors in the output window?

No, there aren’t any errors. (30 chars)

Ok try this:

local Players = game:GetService("Players")
local tool = script.Parent
local plr = Players.LocalPlayer
local gui = nil

tool.Equipped:Connect(function()
   gui = tool.KitchenGuide:Clone()
   gui.Parent = plr:WaitForChild("PlayerGui")
end)

tool.Unequipped:Connect(function()
   gui:Destroy()
end

Edit: Put this in a LocalScript

Still nothing, I put a ) after the end at the ending. The output said it was wrong unless I did that. Still doesn’t work even after doing that. I also have textlabels inside.

Right, um sorry about that ).
I’m not sure why it isn’t working. Try putting print statements inside the functions to see if they’re running.

You have a space in this line: tool.KitchenGuide: Clone()

It should be: tool.Kitchenguid:Clone()

Also, when you say that it doesn’t work, what’s not working? The GUI isn’t disappearing?

EDIT: also, as @rohithsuju12345 just said, you need to say :Destroy() not .Destroy()

Please notify us if it works! :grinning:

Yeah also its better to do :Destroy() instead of .Destroy()

1 Like

This is because the script is not a local script, I have made this mistake and using this plugin I could convert it to a local script and it should work

You don’t really need a plugin to make it a LocalScript. Just copy the code, make a new LocalScript and paste it into that.

1 Like

I know you don’t need a plugin but it is easier to just convert it, it is also handy if you want to convert things like models to folders without making a folder then putting the model in the folder then ungrouping it, it is more convenient

Yeah, I was just saying in the case of scripts you don’t really need it :slight_smile:

1 Like

Doesn’t work after using your tips. Also the GUI doesn’t show. The GUI IS enabled.

While playing, go to the Explorer and check under the PlayerGui to see if it is there or not.

I put a print statement after ui.Parent = game:GetService(“Players”):GetPlayerFromCharacter(script.Parent.Parent).PlayerGui
and it didn’t work.

Did you try using the code I posted?

Yes. I also put it in a local script still didn’t work

As I said before, try checking the explorer while playing.(after equipping the tool that is)