Help with cloning an item from serverstorage

this works and the weapons are not broken but my question is would it be possible to modify it so it only gives certain weapons that the player selected?

Are you trying to clone a Text Property…?, Nvm, Are you trying to like find a tool using a text string?

Yes! of course! When you fire the server you would have to put the players name as a argument and then in the server script you could do if `

game.Players[tostring(TargetPlayer)]

` then you can give the tool to them. By the way like I said target player would be the argument that you would pass from the local script.

By the way the script I made gives it to the player that clicks the button. Isn’t that what you wanted?

Yes i am trying to find a tool with the same name as the button’s text

Not exactly but i think i can make it work how i want to

Is the button a textbox? If so how does the user change its text?

My script may not match your exact needs however with little modification you can make it match your needs. If this method works please mark my message as solved.

Yes the button is a text button the text is changed by the player pressing another button

Alright so basically just use remote events at this point, it’s much better

local event = game:GetService("ReplicatedStorage"):WaitForChild("PurchaseEVENTS");WaitForChild("Purchase")
local button = script.Parent.Parent.Primary
button.MouseButton1Down:Connect(function()
	event:FireServer(button.Text)
end)
---
event.OnServerConnect:Connect(function(__PLAYER,__STRING)
  if ServerStorage:FindFirstChild(__STRING, true) then
      ServerStorage:FindFirstChild(__STRING, true):Clone().Parent = __PLAYER.Backpack
  end
end)

How would i make it give tools based on an object value instead of what ever is in the tools folder?

1 second. Lemme make a script for that.

@Airirusu This is the slab of code I came up with for the remote event server script. local

ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:FindFirstChild("GiveTool")

	local function GiveTool(Tool, quantity, target_player)
		if game.Players:FindFirstChild(tostring(target_player.Name)) then
			task.wait()
			for i=1, tonumber(quantity) do
				Tool.Value:Clone().Parent = game.Players:FindFirstChild(target_player).Backpack
			end
		Event.OnServerEvent:Connect(function(player)
			GiveTool(player.Tool, "1", player)
	end)
	end
end

I rushed the code so don’t expect it to work at once but with little modification it should work.
And here is the script that makes it so when the player joins there is a object value inside them.

game.Players.PlayerAdded:Connect(function(player)

local ObjectValue = Instance.new("ObjectValue")

ObjectValue.Name = "Tool"

ObjectValue.Value = game.ReplicatedStorage.Tools:FindFirstChild("Tool_1")

ObjectValue.Parent = player

end)

thank you so much! were would i put the script the makes the object value?

In serverscriptservice. I hope you found my solution helpful.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.