New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

How to properly instantiate a tool to the player?

Asked by 3 months ago
Edited 3 months ago

I have a script that clones a tool (a pistol) from the ReplicatedStorage and puts it into the target player's Backpack. I can equip/unequip the item but it doesn't seem to work properly (the whole networking and basically working of the pistol scripts bug). If I otherwise put the tool in the Workspace, I can run over it, pick it up and be able to use it perfectly.

For example there's a sword that works perfectly when put directly in the Workspace and then the player runs over it, picks it up and uses it, but when instantiated from the ReplicatedStorage and put it in the Backpack directly it doesn't work.

My main goal is: I have a GUI inventory with weapon icons and when I click a weapon, the script instantiates the tool (weapon) into the player's backpack, but it doesn't work.

Is there something I am missing here? If you have any questions, please ask.

1 answer

Log in to vote
Answered by 3 months ago

lets say ur script to click the tool is inside a button then i think this script will help unless you already have done this local script:

local backpack = game.Players.LocalPlayer.Backpack
game.ReplicatedStorage:WaitForChild("event name"):FireServer(backpack)

server script:

game.ReplicatedStorage:WaitForChild("event name").OnServerEvent:Connect(function(player,backpack)
game.ReplicatedStorage.toolname:Clone().Parent = backpack

maybe you have done this, maybe not idk but it may help you, it just gets the players backpack from the local script over the event and puts the tool there

Genius! KaptonGames 11 — 3mo

Answer this question