I’m trying to be able to buy 2 different swords with a single RemoteEvent. How do I do this?
(It’s not a server-side issue, client-side)
The issue is in checkRocket().
When ClassicalSword is bought, it also returns true for VenomSword; I’m attempting to make it NOT return true if ClassicalSword is bought and VenomSword isn’t. Vice versa.
local Player = game.Players.LocalPlayer
local buyEvent = game.ReplicatedStorage.BuyEvent
local hasWeapon = false
local function checkRocket()
local found = false
for i, v in pairs (Player.Backpack:GetChildren()) do
if v.Name == "ClassicSword" then
found = true
elseif v.Name == "VenomSword" and not v.Name == "ClassicSword" then
found = true
end
end
for i, v in pairs (Player.Character:GetChildren()) do
if v.Name == "ClassicSword" then
found = true
elseif v.Name == "VenomSword" and not v.Name == "ClassicSword" then
found = true
end
end
if found == true then
return true
else
return false
end
end
script.Parent.Frame.Sword1.MouseButton1Click:Connect(function()
if Player.leaderstats and Player.leaderstats.Points.Value >= cost then
hasWeapon = checkRocket()
if not hasWeapon then
buyEvent:FireServer('ClassicSword')
end
end
end)
script.Parent.Frame.Sword2.MouseButton1Click:Connect(function()
if Player.leaderstats and Player.leaderstats.Points.Value >= cost2 then
hasWeapon = checkRocket()
if not hasWeapon then
buyEvent:FireServer('VenomSword')
end
end
end)