So I am trying to write a shop script which automatically loads the selected items data into the Info bar on the right upon the player clicking on the item’s thumbnail in the shop. (GUI below for reference)
Here’s the local script for it (Inside the item’s thumbnail)
local replicatedStorage = game:GetService("ReplicatedStorage")
local selectedItem = script.Parent.Parent.Parent:WaitForChild("SelectedItem")
local selectedImage = script.Parent.Parent.Parent:WaitForChild("ItemDescription").SelectedImage
local selectedName = selectedImage.SelectedName
-- Load
local Player = game.Players.LocalPlayer
local Name = script.Parent.Name -- CAPITAL N FOR PRICE
local name = script.Parent.Name -- lowercase n for image
-- Info
local Info = script.Parent.Parent.Parent.Info
local InfoImage = Info.ItemImage
local InfoName = Info.ItemName
local InfoPrice = Info.ItemPrice
local ValuePrice = Info.Price
script.Parent.MouseButton1Click:Connect(function()
print ("sent")
script.Parent.Parent.Parent.Parent.Click.Playing = true
replicatedStorage.Shop.GetImage:InvokeServer(Player,name)
replicatedStorage.Shop.GetPrice:InvokeServer(Player,Name)
-- Price
local ReturnPrice = replicatedStorage.Shop.GetPrice:InvokeServer(Name)
InfoPrice.Text = ReturnPrice
ValuePrice.Value = ReturnPrice
-- Image
local ReturnImage = replicatedStorage.Shop.GetImage:InvokeServer(name)
InfoImage.Image = ReturnImage
-- Name
InfoName = script.Parent.Name
end)
And the ServerScript
local replicatedStorage = game:GetService("ReplicatedStorage")
local shopItems = game:GetService("ReplicatedStorage"):WaitForChild("ForSale") -- Where tools are held
local shop = replicatedStorage:WaitForChild("Shop")
replicatedStorage.Shop.GetImage.OnServerInvoke = function(Player,name)
print ("Received")
return shopItems[name].Image.Value
end
replicatedStorage.Shop.GetPrice.OnServerInvoke = function(Player,Name)
return shopItems[Name].Price.Value
end
And Here’s the explorer:
When I test the gui and click the “Test” button, nothing happens, and I get no errors either, the print function doesn’t work and neither does the click sound play. Why am I not getting any errors and how can I fix this?
Here’s a video incase you don’t understand: