I'm currently making a gun shop for my zombie game, but I've run into an issue.
I don't have any experience in remote events, so I was wondering if someone could help me.
This normal script is in ServerScriptService
--Variables--
local Button = script.Parent
local Player = game:GetService("Players").LocalPlayer
local RemoteEvent = game:GetService("ReplicatedStorage").BuyRemoteEvent
local PurchaseButton = script.Parent.BuyPrompt.PurchaseButton
local LeaveButton = script.Parent.BuyPrompt.LeaveButton
--Actual Scripting--
local RemoteEvent = game:GetService("ReplicatedStorage").BuyRemoteEvent
local Item = game:GetService("ServerStorage").Guns.FourthGun
RemoteEvent.OnServerEvent:Connect(function(Player, item)
if item == Item.Name then
local Cash = Player.leaderstats.Cash
if Cash.Value >= 50 then
Cash.Value = Cash.Value - 50
Item = Item:Clone()
Item.Parent = Player.Backpack
else
print("Not enough cash")
end
end
end)
This local Script is somewhere deep in StarterGUI
--Variables--
local Button = script.Parent
local Player = game:GetService("Players").LocalPlayer
local RemoteEvent = game:GetService("ReplicatedStorage").BuyRemoteEvent
local PurchaseButton = script.Parent.BuyPrompt.PurchaseButton
local LeaveButton = script.Parent.BuyPrompt.LeaveButton
--Actual Scripting--
script.Parent.MouseButton1Down:Connect(function()
script.Parent.BuyPrompt.Visible = true
end)
LeaveButton.MouseButton1Down:Connect(function()
script.Parent.BuyPrompt.Visible = false
end)
PurchaseButton.MouseButton1Down:Connect(function()
RemoteEvent:FireServer("FourthGun")
end)

6 comments
What do you need help with? https://idownvotedbecau.se/unclear
I need help with remote events overall
Like, do i put it all in one script or in two scripts like that?
Two scripts like that
But for some reason it doesn't work, do you know why?
What do you mean "doesn't work"? http://xyproblem.info