You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I need the RemoteEvent to fire with the correct parameters.
What is the issue? The RemoteEvent doesn’t fire whatsoever, despite the localscript correctly referencing it and firing the server
What solutions have you tried so far? I’ve looked for many solutions, but no errors appear upon running the script, and I am completely stumped
LocalScript
local buygrenade = Utilities.grenade.Buy
local buybomb = Utilities.bomb.Buy
local buyIED = Utilities.IED.Buy
local buymolotov = Utilities.molotov.Buy
local buylandmine = Utilities.landmine.Buy
local buyflare = Utilities.landmine.Buy
local buyammo = Utilities.ammo.Buy
local buywrench = Utilities.wrench.Buy
buygrenade.MouseButton1Click:Connect(function()
purchase:FireServer("utilities", "grenade")
print("Fired Server Successfully!")
end)
Server Script (Both the Event and Script are located in Replicated Storage)
local replicatedStorage = script.Parent
local purchaseEvent = replicatedStorage.purchase
local function purchaseitem(player, category, item)
local playerAP = player.leaderstats.AP.Value
print("received an purchase!".. category .. player.. item .. playerAP)
local Category = replicatedStorage:FindFirstChild(category)
local item = Category:FindFirstChild(item)
local Cost = item.Cost.Value
if playerAP >= Cost then
playerAP = playerAP - Cost
local purchaseditem = item:Clone()
purchaseditem.Parent = player:WaitForChild(category)
end
end
purchaseEvent.OnServerEvent(purchaseitem)
Yes, but they can access the remote event so there shouldn’t be a need for the client to access the server script, of if there are there should be better alternatives.
local replicatedStorage = game:GetService('ReplicatedStorage')
local purchaseEvent = replicatedStorage:FindFirstChild('purchase', false)
local function purchaseitem(player, category, item)
local playerAP = player.leaderstats.AP.Value
print("received an purchase!".. category .. player.. item .. playerAP)
local Category = replicatedStorage:FindFirstChild(category, false)
local item = Category:FindFirstChild(item, false)
local Cost = item:FindFirstChild('Cost', false).Value
if playerAP >= Cost then
playerAP -= Cost
local purchaseditem = item:Clone()
purchaseditem.Parent = player:WaitForChild(category, 10)
end
end
purchaseEvent.OnServerEvent(purchaseitem)
I know you didn’t ask but here’s a little help with referencing the event in replicated storage and a little update to some of the other things you had. Take what you will and leave what you will
What is the purpose of using FindFirstChild for these. I know it’s useful in some cases but here it is 100% confirmed that the children are there and can be read.
It isn’t quite required because you are right, they are confirmed there but I put them there as a fail-safe to make sure that they are actually there and something didn’t happen. Just out of habit not required but just something I do.
No. Nothing can be replicated from ServerScriptService. Not even RemoteEvents. I guess i’ll just leave it in the Workspace, although it irks me a little bit. Or just keep the event in replicatedstorage, and the script seperate. that works too. I’ve figured it out, all i needed to know