NOTICE: This has been solved by simply just going to an older version of the game and doesn’t really need any more help
So I’m trying to make this local script which allows you to buy weapons from a shop GUI via Remote Events. This local script works fine until the “buy portion” of the script, where it fails to fire the Remote Event.
Here’s a short snippet from the local script:
Local Script Snippet
-- NOTE: ALL VARIABLES ARE CORRECT AND THE SCRIPT KNOWS WHAT RSFOLDER IS
if selectedItem.Value ~= nil then
RSFolder.CheckSale:FireServer(selectedItem.Value) -- does nothing
RSFolder.Success.OnClientEvent:Connect(function()
success = true
end)
And here’s a snippet from the server script:
Server Script Snippet
RSbin.CheckSale.OnServerEvent:Connect(function(player,item)
print ("Cool") -- doesn't print
local toolBP = player.Backpack:FindFirstChild(item)
local toolInventory = player.Inventory:FindFirstChild(item)
What makes it even MORE weird, is the fact that I get absolutely no errors or warning in the output AT ALL, so I am essentially trying to repair this completely blindly.
What I would like to know is why this problem is occuring, and how I can attempt to repair it.
Full Local Script
local replicatedStorage = game:GetService("ReplicatedStorage")
local RSFolder = replicatedStorage:WaitForChild(script.Parent.Parent.Parent.Name)
local selectedItem = script.Parent.Parent.Parent:WaitForChild("SelectedItem")
local greenBackground = Color3.fromRGB(2, 234, 111)
local greenBorder = Color3.fromRGB(7, 53, 28)
local redBackground = Color3.fromHSV(234, 34, 2)
local redBorder = Color3.fromHSV(53, 28, 7)
local timeDelay = 2
local success
local canClick = true
print(RSFolder.CheckSale)
-- Limitations
local Max = 5
local Starterpack = game.StarterPack
local Backpack = game.Players.LocalPlayer.Backpack
local Owned = script.Parent.Parent.Owned.Value
local Equipped = script.Parent.Parent.Equipped.Value
if Owned == true then
local Equipped = script.Parent.Parent.Equipped
if Equipped.Value == true then
script.Parent.Text = "Unequip"
else
script.Parent.Text = "Equip"
end
end
-- SOUNDS
local GUI = script.Parent.Parent.Parent.Parent
local Purchase = GUI.GUISounds.Purchased
local Equip = GUI.GUISounds.Equip
local Fail = GUI.GUISounds.Fail
local Both = game.ReplicatedStorage.Saving.Both
script.Parent.MouseButton1Click:Connect(function()
if canClick == true then
Both:FireServer()
-- OWNS ITEM
if Owned == true then
-- IF THE ITEM ISN'T EQUIPPED
if Equipped == false then
-- INVENTORY FULL
local equipsuccess = nil
if selectedItem.Value ~= nil then
equipsuccess = RSFolder.CheckSale:FireServer(selectedItem.Value)
end
if #Backpack:GetChildren() > 5 then
if Equipped == true then
Fail:Play()
RSFolder.Equip:FireServer(Equipped)
script.Parent.Text = ("Unequipped!")
canClick = false
script.Parent.BackgroundColor3 = greenBackground
script.Parent.BorderColor3 = greenBorder
script.Parent.TextColor3 = greenBorder
wait(timeDelay)
script.Parent.Text = ("Equip")
canClick = true
else
Equip:Play()
script.Parent.Text = ("Inventory Full!")
canClick = false
script.Parent.BackgroundColor3 = greenBackground
script.Parent.BorderColor3 = greenBorder
script.Parent.TextColor3 = greenBorder
wait(timeDelay)
script.Parent.Text = ("Unequip")
canClick = true
end
-- INVENTORY NOT FULL
else
if Equipped == true then
Equip:Play()
RSFolder.Equip:FireServer(Equipped)
script.Parent.Text = ("Equipped!")
canClick = false
script.Parent.BackgroundColor3 = greenBackground
script.Parent.BorderColor3 = greenBorder
script.Parent.TextColor3 = greenBorder
wait(timeDelay)
script.Parent.Text = ("Unequip")
canClick = true
else
Equip:Play()
RSFolder.Equip:FireServer(Equipped)
script.Parent.Text = ("Unequipped!")
canClick = false
script.Parent.BackgroundColor3 = greenBackground
script.Parent.BorderColor3 = greenBorder
script.Parent.TextColor3 = greenBorder
wait(timeDelay)
script.Parent.Text = ("Equip")
canClick = true
end
end
end
-- IF THE ITEM ISN'T OWNED
else
success = nil
if selectedItem.Value ~= nil then
RSFolder.CheckSale:FireServer(selectedItem.Value) -- does nothing
RSFolder.Success.OnClientEvent:Connect(function()
success = true
end)
RSFolder.Fail.OnClientEvent:Connect(function()
-- do nothing
end)
end
-- CAN AFFORD ITEM
if success then
Purchase:Play()
canClick = false
script.Parent.BackgroundColor3 = greenBackground
script.Parent.BorderColor3 = greenBorder
script.Parent.TextColor3 = greenBorder
script.Parent.Text = ("Purchased!")
Owned = true
wait(timeDelay)
script.Parent.Text = ("Equip")
canClick = true
-- CAN'T AFFORD ITEM
else
Fail:Play()
canClick = false
script.Parent.BackgroundColor3 = redBackground
script.Parent.BorderColor3 = redBorder
script.Parent.TextColor3 = redBorder
script.Parent.Text = ("Can't Afford!")
Owned = false
wait (timeDelay)
canClick = true
script.Parent.BackgroundColor3 = greenBackground
script.Parent.BorderColor3 = greenBorder
script.Parent.TextColor3 = greenBorder
script.Parent.Text = ("Buy")
end
end
end
end)
Full Server Script
local replicatedStorage = game:GetService("ReplicatedStorage")
local Name = script.Name
local Toolsbin = game:GetService("ServerStorage"):WaitForChild(Name)
local RSbin = replicatedStorage:WaitForChild(Name)
-- IMAGE
RSbin.GetImage.OnServerInvoke = function(player,item)
return Toolsbin[item].TextureId
end
-- PRICE
RSbin.GetInfo.OnServerInvoke = function(player,item)
return Toolsbin[item].Price.Value
end
-- OWNED
RSbin.GetOwnership.OnServerInvoke = function(player,item)
print (item)
if player.Inventory:FindFirstChild(item) then
return true -- if item is found
end
end
-- EQUIPPED
RSbin.Equip.OnServerInvoke = function(player,item)
if player.Backpack:FindFirstChild(item) then
return true
end
end
-- XP
RSbin.GetRequiredXP.OnServerInvoke = function(player,item)
return Toolsbin[item].Lvl.Value
end
-- PURCHASE ATTEMPT
RSbin.CheckSale.OnServerEvent:Connect(function(player,item)
print ("Cool")
local toolBP = player.Backpack:FindFirstChild(item)
local toolInventory = player.Inventory:FindFirstChild(item)
-- If item is in hotbar
if toolBP then
-- If item is also in hidden inventory
if toolInventory then
-- Nothing Happens
else
-- If item isn't also in hidden inventory
toolBP.Parent = player.Inventory
RSbin.Success:FireClient()
end
-- If item is in hidden inventory
else
if toolInventory then
toolInventory.Parent = player.Backpack
-- If item isn't owned
else
local BinItem = Toolsbin[item]
local price = BinItem.Price.Value
if player.leaderstats.Gold.Value >= price then
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - price
local Store = game.ServerStorage:WaitForChild(script.Name)
local ToolSave = Store[item]:Clone()
ToolSave.Parent = player.Inventory
RSbin.Success:FireClient()
else
RSbin.Fail:FireClient()
end
end
end
end)