When I click this button it clones the clothing tool properly but the tool doesnt work properly. It worked before so it has to be this script.
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local M = script.Parent
local C = player.Armor:FindFirstChild(M.Name)
if C ~= nil then
local P = C:Clone()
P.Parent = player.Backpack
end
end)
It’s likely because you’re cloning locally, try cloning from the server through a RemoteEvent and see if that fixes it
1 Like
So you seem to be using a local script. You need to use a server script.
Let me explain server and client for you. The server is everything, and the client is you, and everyone else playing individually. If you clone a tool to your backpack, only the client scripts will work, because the server doesn’t “see” that the tool is in your backpack, only you do, because localscripts run on the client, which is your computer/you.
I explained this badly, so for a better explanation use this: Client-Server Model | Roblox Creator Documentation
You need to use a server script. Let me show you how to fix this.
ServerScript
script.Parent.MouseButton1Click:Connect(function(player)
local M = script.Parent
local C = player.Armor:FindFirstChild(M.Name)
if C ~= nil then
local P = C:Clone()
P.Parent = player.Backpack
end
end)
ClickDetectors always have the player instance, so you never need to create your own variable.
1 Like
MouseButton1Click doesn’t return anything as parameters. @OP would need to use a RemoteEvent
Alright Ill try it right now thanks.
Thank you for saying that I was wondering why it didnt work at first