Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Give a tool to player through GUI button doesnt work for me?

Hello, I'm using this script:

local price = script.Parent.Parent.Price
local tools = game.ReplicatedStorage:WaitForChild("Tools")
local tool = script.Parent.Parent.ItemName
local player = script.Parent.Parent.Parent.Parent.Parent.Parent

script.Parent.MouseButton1Click:Connect(function()
	if player.leaderstats:findFirstChild("Money").Value >= price.Value then
		player.leaderstats:findFirstChild("Money").Value = player.leaderstats:findFirstChild("Money").Value - price.Value
		game.ReplicatedStorage.ShopBuy:FireServer(tool.Value)
	end
end)

but when I click the button, the script take the money from the player but doesnt give the item in the player's inventory.

1 comment

0

You can't leave us without the Script that is responsible for actually giving the Item...

1 answer

it might be that you haven't actually made the character equip the tool. this can be done like this:

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
Humanoid:EquipTool(workspace.Tool)

More info can be found here

1 comment

0

I hope you don't mind me fixing up some stuff^•^

This discussion is preserved as it was. New answers, comments, and votes are closed.