Button click store.
Store works in the original code but no1 sees the tool but the Original person who purchased the tool, the tool is invisible to everyone else.
How do I get the code to work where a remote event is passed through?
Thanks in advance.
Orignial code:
local player=game.Players.LocalPlayer
local leaderboard=player:WaitForChild("leaderstats")
local button=script.Parent
local price=button:WaitForChild("Price")
local item=button:WaitForChild("ItemName")
local rs=game:GetService("ReplicatedStorage")
button.MouseButton1Click:connect(function()
if leaderboard.Coins.Value>=price.Value then
leaderboard.Coins.Value=leaderboard.Coins.Value-price.Value
local item=rs:WaitForChild(item.Value)
item:Clone().Parent=player.StarterGear
item:Clone().Parent=player.Backpack
end
end)
while wait()do
button.Text=item.Value.."-"..price.Value
end
New code in local script for button with REMOTE Event. The RemoteEvent is named tool [inside the button]
local player=game.Players.LocalPlayer
local leaderboard=player:WaitForChild("leaderstats")
local button=script.Parent
local price=button:WaitForChild("Price")
local item=button:WaitForChild("ItemName")
local rs=game:GetService("ReplicatedStorage")
local tool = script.Parent -- the tool
local createPartEvent = rs:WaitForChild("tool")
button.MouseButton1Click:connect(function()
if leaderboard.Coins.Value>=price.Value then
leaderboard.Coins.Value=leaderboard.Coins.Value-price.Value
local item=rs:WaitForChild(item.Value)
createPartEvent:FireServer(tool)
end
end)
ServerScript for passing RemoteEvents [In the ServerScriptService]
local button=script.Parent
local price=button:WaitForChild("Price")
local item=button:WaitForChild("ItemName")
local rs=game:GetService("ReplicatedStorage")
local tool = script.Parent -- the tool
local createPartEvent = rs:WaitForChild("tool")
createPartEvent.OnServerEvent:Connect(function(player,tool)
game:GetService("ReplicatedStorage"):WaitForChild(item.Value)
item.Clone().Parent = player.StarterGear -- poof!
item:Clone().Parent=player.Backpack -- poof!
wait(3) -- poof!
end)

1 comment
pretty good answer; upvote this comment or die