Essentially, what I need is when the Wheat Purchase button is pressed, Wheat Seed bag is given.
When the Rice Purchase Button is pressed, Rice Seed bag is given.
When it Fires the event, the event will run both functions, which will then give 2 tools, rather than 1 individualized tool.
I have tried Creating 2 different Variable function names to make both singular, and fire each individual Event when the buttons are pressed accordingly.
Still fires both, and 2 Seed bags go to the players backpack.
I need to fix the Remote Event Script, to where when an individual button is pressed, that it will Fire the Event, and fire a copy of the tool to the backpack.
Currently, it will give 2 tools when Either button is pressed.
- Seedbag Script
-- Variables
local wheat = script.Parent.WheatButton
local rice = script.Parent.RiceButton
local sugarcane = script.Parent.SugarcaneButton
local seedbags = game.Lighting.Seedbags
local player = game.Players.LocalPlayer
local N = 1
-- Value Variables
local wheatAmount = wheat.AmountValue
local riceAmount = rice.AmountValue
local sugarcaneAmount = sugarcane.AmountValue
-- Functions
-- Script Logic
wheat.MouseButton1Click:Connect(function()
if wheatAmount.Value >= 1 then
wheatAmount.Value -= 1
game.ReplicatedStorage.RemoteEvent:FireServer(A1)
end
end)
rice.MouseButton1Click:Connect(function()
if riceAmount.Value >= 1 then
riceAmount.Value -= 1
game.ReplicatedStorage.RemoteEvent:FireServer(players2)
end
end)
while wait() do
task.wait(.5)
wheat.AmountLabel.Text = wheatAmount.Value
rice.AmountLabel.Text = riceAmount.Value
sugarcane.AmountLabel.Text = sugarcaneAmount.Value
end
- Remote Event Script
game.Players.PlayerAdded:Connect(function(player)
-- Variables
local wheat = game.StarterGui.SeedStorageGui.PrimaryFrame.WheatButton
local seedbags = game.Lighting.Seedbags
local wheatAmount = wheat.AmountValue
-- Functions
-- Script Logic
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(A1)
local wheatBag = seedbags.Wheat:Clone()
wheatBag.Parent = player.Backpack
print("Worked!")
end)
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(players2)
local riceBag = seedbags.Rice:Clone()
riceBag.Parent = player.Backpack
print("Worked!")
end)
end)