function buy()
local player = game.Players.LocalPlayer
local Tool = player.Backpack:FindFirstChild("Radar")
local C4 = game.Lighting.OKand
local cloned = C4:Clone()
local Tool2 = player.Backpack:FindFirstChild("Gift")
if Tool and Tool2 then
cloned.Parent = player.Backpack
Tool:Destroy()
Tool2:Destroy()
end
end
script.Parent.MouseButton1Down:connect(buy)
that’s where the script is.
so basically this script is supposed to detect if a player has the tools both (“Radar”, and “Gift”)
when it detects both of them its supposed to remove them and give a new tool call “C4”
but i dont know what im doing wrong
local button = script.Parent
function buy()
local player = game.Players.LocalPlayer
local Tool = player.Backpack:FindFirstChild('Radar')
local C4 = game.Lighting.OKand
local cloned = C4:Clone()
local Tool2 = player.Backpack:FindFirstChild('Gift')
if Tool and Tool2 then
cloned.Parent = player.Backpack
Tool:Destroy()
Tool2:Destroy()
end
end
script.Parent.MouseButton1Down:Connect(buy)
The tool will only be removed from the client side, plus this is done on a SERVER SCRIPT which you will not be able to get the LocalPlayer that way
You have to use RemoteEvents if you want to destroy the tools from the server side, and change it to a LocalScript:
--Client
local Button = script.Parent
local Player = game.Players.LocalPlayer
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local function Buy()
local Tool = player.Backpack:FindFirstChild("Radar")
local Tool2 = player.Backpack:FindFirstChild("Gift")
if Tool and Tool2 then
Event:FireServer() --Instead of destroying the tools on the client side, instead fire an event to the server to destroy the tools that way
end
end
script.Parent.MouseButton1Down:Connect(Buy)
--Server Script inside ServerScriptService
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local C4 = game.Lighting.OKand
Event.OnServerEvent:Connect(function(Player)
Player.Backpack.Radar:Destroy()
Player.Backpack.Gift:Destroy()
local GearClone = C4:Clone()
GearClone.Parent = Player.Backpack
local GearClone = C4:Clone()
GearClone.Parent = Player.StarterGear
end)