I was making when a player touches a part the frame would be visible but its apparently not working?
Server Script
for i,ShopBuyParts in pairs(BuyShop:WaitForChild("ShopPad"):GetChildren()) do
ShopBuyParts.Touched:Connect(function(Hit)
if ShopDebounce == false then
ShopDebounce = true
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player then
RemoteEvents.BuyingEvent:FireClient(Player)
print("Fired Remote Event")
end
task.wait(2)
ShopDebounce = false
end
end)
end
Local Script
RemoteEvents.BuyingEvent.OnClientEvent:Connect(function(Player)
ShopFrame.Visible = not ShopFrame.Visible
end)
It also prints after I fired the Remote Event but doesn’t pick up on the client
I am honestly surprised that worked. I didn’t think that would solve it, was just aimed at code readability (no sense marking that you will receive a variable you don’t want to receive)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local ShopItemsStats = ReplicatedStorage:WaitForChild("ShopItemsStats")
local Map = game.Workspace.Map
local Shops = Map:WaitForChild("Shops")
local BuyShop = Shops:WaitForChild("BuyShop")
local SellShop = Shops:WaitForChild("SellShop")
local Plots = Map:WaitForChild("Plots")
local MainGui = Player.PlayerGui:WaitForChild("MainGui")
local ShopFrame = MainGui:WaitForChild("ShopFrame")
local SeedsFrame = MainGui:WaitForChild("SeedsFrame")
local ShopScrollingFrame = ShopFrame:FindFirstChild("ShopScrollingFrame")
local BuyingItemFrame = ShopFrame.BuyingItemFrame
local BuyItemButton = BuyingItemFrame:FindFirstChild("BuyButton")
RemoteEvents.BuyingEvent.OnClientEvent:Connect(function()
print("Working..")
ShopFrame.Visible = not ShopFrame.Visible
end)
local ItemDebounce = true
for i,Item in pairs(ShopItemsStats:GetChildren()) do
local ItemButton = Instance.new("ImageButton")
ItemButton.ScaleType = Enum.ScaleType.Fit
ItemButton.BackgroundColor3 = Color3.new(1, 0.937255, 0.803922)
ItemButton.Image = Item.TextureId
ItemButton.BorderSizePixel = 0
ItemButton.Parent = ShopScrollingFrame
ItemButton.Size = UDim2.new(0, 100,0, 104)
ItemButton.MouseButton1Click:Connect(function()
BuyingItemFrame.Visible = true
BuyingItemFrame.ItemName.Text = Item.Name
BuyingItemFrame.ItemImage.Image = Item.TextureId
BuyingItemFrame.CostLabel.Text = "Cost: " .. Item:WaitForChild("CostValue").Value
BuyingItemFrame.QuantityLabel.Text = "Quantity:" .. Item:WaitForChild("QuantityValue").Value
end)
end
BuyItemButton.MouseButton1Click:Connect(function()
if ItemDebounce == true then
ItemDebounce = false
local ItemPlayerGoingToBuyName = BuyingItemFrame:WaitForChild("ItemName").Text
RemoteEvents.BuyingEvent:FireServer(ItemPlayerGoingToBuyName, BuyingItemFrame)
task.wait(.5)
ItemDebounce = true
end
end)
RunService.RenderStepped:Connect(function()
if Mouse.Target and Mouse.Target.Name == "Carrot" then
if Mouse.Target:FindFirstChild("Grown") then
if Mouse.Target:FindFirstChild("Grown").Value == true then
SeedsFrame.Visible = true
SeedsFrame:WaitForChild("GrownLabel").Text = "Fully Grown"
local X = Mouse.X
local Y = Mouse.Y
SeedsFrame.Position = UDim2.new(0,X,0,Y)
else
local X = Mouse.X
local Y = Mouse.Y
SeedsFrame.Position = UDim2.new(0,X,0,Y)
SeedsFrame.Visible = true
SeedsFrame:WaitForChild("GrownLabel").Text = "Growing"
end
end
elseif Mouse.Target and Mouse.Target.Name == "PineApple" then
if Mouse.Target:FindFirstChild("Grown") then
if Mouse.Target:FindFirstChild("Grown").Value == true then
SeedsFrame.Visible = true
SeedsFrame:WaitForChild("GrownLabel").Text = "Fully Grown"
local X = Mouse.X
local Y = Mouse.Y
SeedsFrame.Position = UDim2.new(0,X,0,Y)
else
local X = Mouse.X
local Y = Mouse.Y
SeedsFrame.Position = UDim2.new(0,X,0,Y)
SeedsFrame.Visible = true
SeedsFrame:WaitForChild("GrownLabel").Text = "Growing"
end
end
else
SeedsFrame.Visible = false
end
end)
This is the Server Script
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Map = game.Workspace:WaitForChild("Map")
local Shops = Map:WaitForChild("Shops")
local BuyShop = Shops:WaitForChild("BuyShop")
local SellShop = Shops:WaitForChild("SellShop")
local PlotsFolder = Map:WaitForChild("Plots")
local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local ShopItems = ServerStorage:WaitForChild("ShopItems")
local MaterialBlockFolder = ServerStorage:WaitForChild("Materials")
local MaterialSeedsFolder = ServerStorage:WaitForChild("Seeds")
local Effects = ServerStorage:WaitForChild("Effects")
local ShopDebounce = false
for i,ShopBuyParts in pairs(BuyShop:WaitForChild("ShopPad"):GetChildren()) do
ShopBuyParts.Touched:Connect(function(Hit)
if ShopDebounce == false then
ShopDebounce = true
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player then
RemoteEvents.BuyingEvent:FireClient(Player)
end
task.wait(2)
ShopDebounce = false
end
end)
end
function PlayerJoined(Player)
local leaderstats = Instance.new("Folder")
leaderstats.Parent = Player
leaderstats.Name = "leaderstats"
local Coins = Instance.new("IntValue")
Coins.Parent = leaderstats
Coins.Name = "Coins"
Coins.Value = 500
local PlayerOwns = Instance.new("BoolValue")
PlayerOwns.Name = "PlayerOwns"
PlayerOwns.Parent = Player
PlayerOwns.Value = false
task.wait(4)
for i, Plot in pairs(PlotsFolder:GetChildren()) do
if Plot:FindFirstChild("Owned").Value == false and PlayerOwns.Value == false then
Player.Character:FindFirstChild("HumanoidRootPart").CFrame = Plot:WaitForChild("PlayerSpawn").CFrame
Plot:WaitForChild("Owned").Value = true
PlayerOwns.Value = true
Plot:WaitForChild("PlayerOwns").Value = Player.Name
end
end
end
function PlayerLeft(Player)
for i, Plot in pairs(PlotsFolder:GetChildren()) do
if Plot:FindFirstChild("PlayerOwns").Value == Player.Name then
Plot:FindFirstChild("PlayerOwns").Value = ""
Plot:FindFirstChild("Owned").Value = false
Plot.Seeds:Destroy()
end
end
end
RemoteEvents.BuyingEvent.OnServerEvent:Connect(function(Player, ItemPlayerGoingToBuyName, BuyingItemFrame)
if ItemPlayerGoingToBuyName then
local Item = ShopItems:WaitForChild(ItemPlayerGoingToBuyName)
local PlayerOwnsTool = Player.Backpack:FindFirstChild(Item.Name) or Player.Character:FindFirstChild(Item.Name)
if PlayerOwnsTool then
if Player.leaderstats.Coins.Value >= Item.CostValue.Value then
BuyingItemFrame.BuyButton.Text = "Buying.."
task.wait(.2)
Player.leaderstats.Coins.Value -= Item.CostValue.Value
PlayerOwnsTool.Handle.Quantity.Value += Item.QuantityValue.Value
task.wait(.3)
BuyingItemFrame.BuyButton.Text = "Buy"
elseif Item.CostValue.Value >= Player.leaderstats.Coins.Value then
BuyingItemFrame.BuyButton.BackgroundColor3 = Color3.new(1, 0.2, 0.2)
task.wait(.5)
BuyingItemFrame.BuyButton.Text = "Not Enough!"
BuyingItemFrame.BuyButton.Text = "Buy"
BuyingItemFrame.BuyButton.BackgroundColor3 = Color3.new(0.333333, 1, 0.498039)
end
end
if Player.leaderstats.Coins.Value >= Item.CostValue.Value and PlayerOwnsTool == nil then
BuyingItemFrame.BuyButton.Text = "Buying.."
task.wait(.2)
Player.leaderstats.Coins.Value -= Item.CostValue.Value
local ItemClone = Item:Clone()
ItemClone.Parent = Player.Backpack
task.wait(.3)
BuyingItemFrame.BuyButton.Text = "Buy"
elseif Item.CostValue.Value >= Player.leaderstats.Coins.Value then
BuyingItemFrame.BuyButton.Text = "Not Enough!"
BuyingItemFrame.BuyButton.BackgroundColor3 = Color3.new(1, 0.2, 0.2)
task.wait(.5)
BuyingItemFrame.BuyButton.Text = "Buy"
BuyingItemFrame.BuyButton.BackgroundColor3 = Color3.new(0.333333, 1, 0.498039)
end
end
end)
RemoteEvents.PlacingEvent.OnServerEvent:Connect(function(Player, Material, MaterialPosition, PlotSpaceEmptyValue)
PlotSpaceEmptyValue.Value = false
Material:FindFirstChild("Handle").Quantity.Value -= 1
if MaterialBlockFolder:FindFirstChild(Material.Name) then
elseif MaterialSeedsFolder:FindFirstChild(Material.Name) then
for i,Plot in pairs(PlotsFolder:GetChildren()) do
if Plot:FindFirstChild("PlayerOwns").Value ~= Player.Name then
else
local MaterialClone = MaterialSeedsFolder:FindFirstChild(Material.Name):Clone()
MaterialClone.Grown.Value = false
MaterialClone.CanCollide = false
MaterialClone.Anchored = true
MaterialClone.Position = MaterialPosition
MaterialClone.PlayerPlanted.Value = Player.Name
MaterialClone.PlotFlag.Value = PlotSpaceEmptyValue
MaterialClone.Parent = Plot:FindFirstChild("Seeds")
local PlacingEffect = Effects:WaitForChild("PlacingEffect"):Clone()
PlacingEffect.Parent = MaterialClone
task.wait(.4)
PlacingEffect:Destroy()
end
end
end
end)
game.Players.PlayerAdded:Connect(PlayerJoined)
game.Players.PlayerRemoving:Connect(PlayerLeft)