I have a localscript which has a MouseButton1Click. Now in that Click, I want to clone an object and put it in the clicker's backpack. Realising I can only do that in a normal script, I insert a RemoteEvent inside the Replicated Storage. After that, in a script which has the "OnServerEvent" inside ServerStorage, it will not receive, or the RemoteEvent doesn't fire. I think it's the OnServerEvent won't receive, because of the explanation below.
--LocalScript local CanBuy = true --Checking if the player can buy the item local player = game.Players.LocalPlayer --Defining player local GC = game.Workspace.SI.GravityCoil --Defining the place where Gravity Coil is local E = game.ReplicatedStorage.RemoteEvent --Defining the location of RemoteEvent local GCT = player.PlayerGui.Gui.SpecialItemsFrame.GravityCoil.GravityCoilBuy --Defining a text message script.Parent.MouseButton1Click:Connect(function() --The Mouse Click if CanBuy then --If CanBuy is true, which it is from the 1st line. print(player.Name) --Checks who did it E:FireServer(GC) --Fires the server, and has GC. CanBuy = false --CanBuy is now false, so we wait for a bit until the person can rebuy the item. GCT.TextColor3 = Color3.fromRGB(255,0,0) --Changes the textcolor to red/ for i = 10, 0, -1 do print(i) GCT.Text = i wait(1) -- This 'for i' is just basically a countdown until the person can rebuy it end CanBuy = true --CanBuy is set to true again, meaning that the person can get it again, the server is now fired again. GCT.TextColor3 = Color3.fromRGB(0, 163, 0) --Changes the color to green GCT.Text = "Take Here" --This was the original message. end end)
Now here was my script in ServerScriptService
--Script game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, Coil) print("Received") Coil:Clone().Parent = player.Backpack --Clones the Coil, and the parent is the backpack. end)
I do not receive the print message. However, I could tell that it's just not receiving, as the localscript runs every line with no errors (meaning the countdown and all works).
I checked this with some people on discord scripting helpers, and they say the code is all right. So why won't this work?