#Help me fix my Purchasing system

1 messages · Page 1 of 1 (latest)

grave steeple
#

Alright so i have this purchasing system thats meant to work on one gui but give a dif tool based on which proximityprompt was triggered. But i dont know why it doesnt work (im a new scripter)

SERVER SCRIPT:
local Prox = script.Parent
local Tool = Prox.ClassicSword
local Cost = Prox.ToolCost
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("OpenToolBuy")
local Event2 = RS:WaitForChild("BuyTool")
Prox.Triggered:Connect(function(Player)
Event:FireClient(Player)
if Player.leaderstats.Cash.Value == Cost then
Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value - Cost
Event2.OnClientEvent:Connect(function()
local ToolClone = Tool:Clone()
ToolClone.Parent = Player.Backpack
Prox.Parent:Destroy()
end)
end
end)

Client Script:
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("BuyTool")
local Button = script.Parent
local Player = game.Players.LocalPlayer
Button.MouseButton1Click:Connect(function()
Event:FireClient(Player)
end)

vale rain
#

I think you switched up client and server

#

On ts message

#

Its a lil weird

#

Because you are firing client on both scripts?

#

You meant Event:FireServer() in the client script

#

Not fireclient(player)

#

?

tribal loom
#

bro FireClient only works on the server

grave steeple
#

@tribal loom @vale rain yea guys i know i just copy and pasted an older message thst part is fixed

#

But it still didint work

#

Even tho i switched the remote events

chilly nova
#

your script is a bit weird

grave steeple
#

@chilly nova doesnt matter.

#

just fix it

#

it may be odd but if it works im fine with it

chilly nova
#

Wait

#

ServerScript: local Prox = script.Parent
local Tool = Prox.ClassicSword
local Cost = Prox.ToolCost
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("OpenToolBuy")
local Event2 = RS:WaitForChild("BuyTool")

Prox.Triggered:Connect(function(Player)
Event:FireClient(Player)
end)

Event2.OnServerEvent:Connect(function(Player)
if Player.leaderstats.Cash.Value >= Cost then
Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value - Cost
local ToolClone = Tool:Clone()
ToolClone.Parent = Player.Backpack
Prox.Parent:Destroy()
end
end)

#

Client:

local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("BuyTool")
local Button = script.Parent

Button.MouseButton1Click:Connect(function()
Event:FireServer()
end)

grave steeple
#

@chilly nova yea for some reason it doesnt work

#

@chilly nova Alright look heres the thing, My Roblox game relies on this beacause there is a bug, and i think this gui thingy is the way to fix it. So ill let you do anything to fix it

chilly nova
#

Wait

#

use RS.OpenToolBuy instead of WaitForChild()

#

sometimes it works

#

is there any error in output btw?

grave steeple
#

@chilly nova no nothing in output

#

it doesnt work like at all

#

the button doesnt work

#

and it doesnt even come up

#

from the proximityprompt

vale rain
#

Wai whats the script now?