You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to have a remote event to clone and re-parent an object when fired.
What is the issue? Include screenshots / videos if possible!
The remote event simply wont fire. (The rest of the local script runs fine)
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I looked at previous devforum posts and requested help on RSC.
Client
local MPS = game:GetService("MarketplaceService")
local RS = game:GetService("ReplicatedStorage")
local event = RS:WaitForChild("BoughtItem")
local player = game:GetService("Players").LocalPlayer
for i, button in ipairs(script.Parent:GetChildren()) do
if button:IsA("TextButton") then
button.MouseButton1Click:Connect(function()
if button:FindFirstChild("PurchaseID") then
MPS:PromptProductPurchase(player,button.PurchaseID.Value)
MPS.PromptProductPurchaseFinished:Connect(function(playerID, productID, purchased)
if purchased then
print("purchased")
event:FireServer(button.Name)
end
end)
end
end)
end
end
Server
local RS = game:GetService("ReplicatedStorage")
local event = RS:FindFirstChild("BoughtItem")
event.OnServerEvent:Connect(function(player, itemName)
print("fired")
local tool = game.ServerStorage.Assets:FindFirstChild(itemName):Clone()
tool.Parent = player.Backpack
end)
PromptProductPurchaseFinished this event does not fire to the client I believe and should really be used on a server side script. So in a server script you need on single event that listens for these signals, and then process that in a single script.
OK, understood. I still think that the event would be best caught on the server, as the client could easily spoof remote and obtain the item. Try changing the serverside script to capture the event instead:
MPS.PromptProductPurchaseFinished:Connect(function(playerID, productID, purchased)
if purchased then
print("purchased"), playerID,
local tool = game.ServerStorage.Assets:FindFirstChild(itemName):Clone()
tool.Parent = player.Backpack
end
end)
As an after thought, have you confirmed that RS:FindFirstChild("BoughtItem") is a RemoteEvent? Sometimes it’s easy to overlook the obvious.
Hi, I have read from others on DevForum that they have had issues with new RemoteEvents. You could try recreating the remote itself and see if that resolves the matter. Other than that, they are supposed to be fairly straight forward to use, so not sure how to guide you further.
Hey everyone, found my issue. It was the server’s end. For whatever reason, the script couldn’t detect when the RemoteEvent was getting fired from the workspace, so I moved the script to ServerScriptService and edited it.