#I Need help with my Purchasing Script

1 messages · Page 1 of 1 (latest)

limber anchor
#

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)

hybrid iron
#

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)

#

@limber anchor you messed up fireserver and fireclient

#

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.OnServerEvent: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:FireServer()
end)

limber anchor
#

@hybrid iron thanks

hybrid iron
#

Np

limber anchor
#

@hybrid iron Yea unfortenally it doesnt work

hybrid iron
#

error

limber anchor
#

well firstly the purchase prompt wont even open

#

and i tried to make it visible

#

and just to see if the buying works

#

but that doesnt either

#

@hybrid iron

#

also output shows nothing

hybrid iron
limber anchor
#

its a number value

#

is that the same?

hybrid iron
#

but you gotta do .Value

limber anchor
#

local Prox = script.Parent
local Tool = Prox.ClassicSword
local Cost = Prox.ToolCost.Value
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.Value then
Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value - Cost.Value
Event2.OnServerEvent:Connect(function()
local ToolClone = Tool:Clone()
ToolClone.Parent = Player.Backpack
Prox.Parent:Destroy()
end)
end
end)

#

well

#

it still didint work

#

maybe i did it wrong?

#

@hybrid iron

hybrid iron
#

what are you trying to achieve

limber anchor
#

purchasing script that works on 1 gui

#

and MULTIPLE Tools

#

like i dont want to make multiple purchase notfiers for every tool yk

#

@hybrid iron

hybrid iron
#

i cant seem to be finding the logic error

limber anchor
#

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

#

is everything ok in this? @hybrid iron

#

this is in the buy button

limber anchor
#

i mean for gui it is mousebutton1click

#

but alright...

#

yea no it doesnt work either

hybrid iron
#

i got no clue, @scenic wigeon do you know?

limber anchor
#

maybe he can

#

he seems pretty pro

limber anchor
#

@scenic wigeon

scenic wigeon
#

why me agony

hybrid iron
#

ur the only one i know thats good

scenic wigeon
unique summitBOT
#

studio** You are now Level 51! **studio

limber anchor
#

Event1 is for opening the gui

#

Event2 is for Purchasing

#

@scenic wigeon