###This will be a LocalScript under your TextButton or ImageButton. I will be using RemoteEvents and RemoteFunctions, as ROBLOX may be removing experimental mode. Learn more on that here.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BuyRemotes = ReplicatedStorage:WaitForChild("BuyWeaponRemotes")
local CheckPrice = BuyRemotes:WaitForChild("CheckPrice")
local CloneTool = BuyRemotes:WaitForChild("CloneTool")
local Price = CheckPrice:InvokeServer("Sword")
local player = Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
CloneTool:FireServer("Sword", Price)
end)
###Server code, recommend to put it in ServerScriptService.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BuyRemotes = ReplicatedStorage:WaitForChild("BuyWeaponRemotes")
local CheckPrice = BuyRemotes:WaitForChild("CheckPrice")
local Weapons = ReplicatedStorage:WaitForChild("Weapons")
local CloneTool = BuyRemotes:WaitForChild("CloneTool")
local GetPrice = function(player, toolName)
return Weapons[toolName].Price.Value
end
CheckPrice.OnServerInvoke = GetPrice
CloneTool.OnServerEvent:Connect(function(player, toolName, price)
end
end)
###I won't give the full code. Though there's a basic understanding on how. Here's a few things that you should read.
https://devforum.roblox.com/t/changes-to-playing-ability-of-experimental-mode-games/146494.
http://robloxdev.com/articles/Remote-Functions-and-Events
5 comments
Please post your code. It helps a lot.
Edited, not much, but that is why I posted here.
Will your shop be physical (a building obviously) or a GUI?
GUI. A Dialog GUI. It brings the shop up. I am trying to connect the buttons to reduce your credits,and clone the weapon from replicatedstorage.
I created the credits USING datastorage. How do I talk to that with the button script to further reduce the integer?