Tool that appears when GUI is opened

I’ve been trying to make it to where a phone appears in your hand when you open the phone GUI in my game, I ended up giving up and deleting all my code, I know nothing about coding and it was not working whatsoever, can somebody help me with it? All tutorials on YouTube are “How to make a GUI When Tool Is Equipped” and not “How to make a Tool when a GUI is opened”. Can someone please help me?

Okay, this is easy you would check if it’s enabled or not Add a Local script inside of the gui.

local GUI =  script.Parent
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
if GUI.Enabled == true then
-- make the tool appear
end)
1 Like

try this instead:

script.Parent:GetPropertyChangedSignal(“Enabled”):Connect(function()
if script.Parent.Enabled == true then
–make the tool appear–
end
end)

1 Like

How would I make it to where they can’t unequip the tool unless the GUI is disabled? Also thank you!

it’s kind of unnecesary to use renderstepped to check if the gui is enabled.
renderstepped is a function that fires every time a frame gets rendered so it is better to use propertychangedsignal

Alright, but how do I make the tool appear? It’s gonna be stored in ServerStorage, and I want it to only disappear if the GUI goes away, not if you unequip the tool. How would you do that?

It won’t work for ServerStorage add it in ReplicatedStorage. Since this is a Local script not Server script.

local GUI =  script.Parent
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
if GUI.Enabled == true then
-- make the tool appear
elseif GUI.Enabled == false then
Tool:Destroy()
end)
2 Likes

you got a point, client can’t acces to serverstorage

Alright, I’ll put it into ReplicatedStorage then, thank you guys for all the help, is there a way to make it to where you can’t unequip the tool and it only unequips once the GUI is gone? I know he put it to where it destroys in the script and stuff, but how do I make it to where you can’t unequip it manually?

you can’t disable unequipping so use a model instead of a tool.

Make a primarypart for the phone and set it’s position to whatever spot you want your character to hold it.
Unanchor all of the phone parts and weld them together

–Equip–
local Phone = game.ReplicatedStorage.Phone:Clone()
local weld = Instance.new(“WeldConstraint”)
weld.Part0 = Phone.PrimaryPart
weld.Part1 = game.Players.LocalPlayer.Character.RightHand
weld.Parent = phone.PrimaryPart
Phone:SetPrimaryPartCFrame(game.Players.LocalPlayer.Character.RightHand.CFrame)
Phone.Parent = game.Players.LocalPlayer.Character

–Unequip–
game.Players.LocalPlayer.Character.Phone:Destroy()

Alright! Thank you! Will other players be able to see the phone in the hand too?

no as it is a localscript, if you want you could use remotes to create the phone

Oh, well as long as it shows up for the player themselves, that’s all that matters!

1 Like

“Model:SetPrimaryPartCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this. - Client - LocalScript:9”

I’m not quite sure what you meant by seat PrimaryPart…??

Okay so I fixed everything, but this is what the phone looks like in the hand… or in the arm. Is there any way to fix it?

calibrate the primary part’s orientation until you get what you want