Script on Tool wont work unless in starterpack

Hey so, I’m trying to make it so if I equip this tool, it’ll clone the “equip” gui to the player’s playergui but it just wont work unless it’s in starterpack. RequireHandle is false but even if I turn it into true it still wont work!

Tool

image

GUI Clone Script
Tool = script.Parent

function onEquippedLocal()
	local Character = Tool.Parent
	local Player = game.Players:GetPlayerFromCharacter(Character)
	Gui = script.Parent.Equip:Clone()
	Gui.Parent = Player.PlayerGui
	Gui.Name = script.Parent.Name
end

function onUnequippedLocal()
	Gui:Remove()
end

Tool.Equipped:Connect(onEquippedLocal)
Tool.Unequipped:Connect(onUnequippedLocal)

It’s on replicated storage

Thanks in advance, :happy4:

1 Like

It needs to be a localscript, the player cannot run scripts only the server can

1 Like

Change the script to a local script. Server scripts inside of StarterPack won’t run, local scripts will however.

1 Like

It still doesn’t work even if I turned it into a localscript for some reason :frowning:

1 Like

Snipping this since irrelevant.

1 Like

Where is the tool currently located?

1 Like

It’s located in replicatedstorage

1 Like

Okay, so it works in StarterPack are you trying to get it to work if cloned to the player’s backpack?

1 Like

Yep! That’s what I’m trying to do, and when you equip the tool the gui gets cloned to the playergui of the player and when unequipped then the gui will be deleted

1 Like

Yeah, just copy and paste the script into a local script & it should work, I tested.

Tool = script.Parent

function onEquippedLocal()
	local Character = Tool.Parent
	local Player = game.Players:GetPlayerFromCharacter(Character)
	Gui = script.Parent.Equip:Clone()
	Gui.Parent = Player.PlayerGui
	Gui.Name = script.Parent.Name
end

function onUnequippedLocal()
	Gui:Remove()
end

Tool.Equipped:Connect(onEquippedLocal)
Tool.Unequipped:Connect(onUnequippedLocal)
1 Like

a.rbxl (31.1 KB)

Here’s the place file, the tool is in RepStorage, I have a script move the tool to the player’s backpack. Check it out.

1 Like

This is very frustrating but my tool wont work with even the script pasted into a localscript :frowning: :angry: I’m gonna try modifying your tool to see if it’ll work

In your screenshot the local script is disabled. Not sure if that’s the one which you pasted the code inside.

Nope that’s not it. But for some reason the tool works if I don’t paste it from replicatedstorage to my backpack, instead I use my inventory system to get the tool and it’ll work perfectly :+1:

I’m not sure if you checked the above file out but the script clones the tool from ReplicatedStorage to the backpack and when the tool is equipped the UI appears & then disappears once the tool is unequipped.

Yep, that’s what i checked and then I checked if when I clone the item automatically instead of cloning it manually it does work.

What do you mean by cloning it manually? There’s only one way to clone an instance, that’s with the :Clone() function.

When I was cloning it, I was doing the CTRL + C then CTRL + V method from it’s original location onto my backpack to clone it.

Oh right, yeah that likely won’t work. Not sure why you’d want to do that way anyway since other players won’t be able to get the tool like that.