#RemoteEvent isn't firing

6 messages · Page 1 of 1 (latest)

vale trellis
#

Idk what exactly is happening, but either the remote event wont fire or the server isn't detecting when its fired

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
                        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)
    local tool = game.ServerStorage.Assets:FindFirstChild(itemName):Clone()
    tool.Parent = player.Backpack
end)
winter leaf
#
local MPS = game:GetService("MarketplaceService")
local RS = game:GetService("ReplicatedStorage")
local event = nil
local player = game:GetService("Players").LocalPlayer

MPS.PromptProductPurchaseFinished:Connect(function(playerID, productID, purchased,button)
    if purchased then
        event:FireServer(button.Name)
    end
end)

for i, button in ipairs(script.Parent:GetChildren()) do
    if button:IsA("TextButton") then
        button.MouseButton1Click:Connect(function()
            if button:FindFirstChild("PurchaseID") then
                event = RS:WaitForChild("BoughtItem")
                MPS:PromptProductPurchase(player,button.PurchaseID.Value)
            end
        end)
    end
end```
#

ServerSide```lua
local RS = game:GetService("ReplicatedStorage")
local event = RS:FindFirstChild("BoughtItem")
if event then
event.OnServerEvent:Connect(function(player, itemName)
local tool = game.ServerStorage.Assets:FindFirstChild(itemName)
if tool then
tool:Clone().Parent = player.Backpack
else
print(itemName.." does not exist in ServerStorage.Assets")
end
end)
else
print("Event 'BoughtItem' does not exist in ReplicatedStorage.")
end

vale trellis
#

the remote event still wont fire

vale trellis
#

@winter leaf