Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

OnServerEvent function wont detect a firing remote event?

localscript inside the players gui:

local plr = game.Players.LocalPlayer

local char = plr.Character

script.Parent.MouseButton1Click:Connect(function()

script.Parent.ReturnCamera.Disabled = false

script.Parent.Parent.Parent.LobbyGui.Enabled = true

script.Parent.Parent.Enabled = false

wait()

script.Parent.ReturnCamera.Disabled = true

--collect and send data to users serverfolder--

local folder = game.ReplicatedStorage.userDataStorage:FindFirstChild("CartData:"..char.Name)

if folder == nil then

print("folder nil")

end

if folder ~= nil then

print("folder not nil")

local carttype = script.Parent.Parent.Parent.CustomData.CartType.Value

local colortype = script.Parent.Parent.Parent.CustomData.ColorType.Value

folder.ChangeData:FireServer(carttype,colortype)

print("sent data")

end

-----------------------

wait()

script.Disabled = true

end)

script inside replicated storage:

script.Parent.ChangeData.OnServerEvent:Connect(function(plr,carttype,colortype)

print("recieved data at RS")

script.Parent.CartType.Value = carttype

script.Parent.ColorType.Value = colortype

print("data set")

end)

there is a folder inside replicatedstorage that is labeled "CartData" with a players name at the end. Im trying to send data from the folder owner's gui over to that folder but it seems to not read off of it. the localscript successfully fires to the remote event, but the remote event listening script doesn't detect it. help?

1 answer

you need to wait for the remote event so do local folder = game.ReplicatedStorage:WaitForChild("remoteevent name")

2 comments

0

that didnt work, I was able to print the name of both the remote event and the folder owner's name, but it still refuses to fire the remote event.

0

did u do it on both scripts, u always need to wait for the remote event in all scripts

This discussion is preserved as it was. New answers, comments, and votes are closed.