Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why won't my remote event run, let alone the entire script?

Asked by
Storche 13
4 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
Player = game.Players.LocalPlayer
mouse = Player:GetMouse()

Enabled = true

mouse.Button1Down:connect(function()
    if Enabled == true then
        script.Function:FireServer("Print")
        print("1")
    end
end)

--2nd script


script.Parent.OnServerEvent:Connect(function()
        print("2")

end)

0
roblox is currently experiencing issues with scripts right now so that why and another reason could be because Player need to be set as a local coolmanHDMI 72 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Hello.

Problem:

1.You must've put the LocalScript in the wrong spot. Local scripts can only run on the following:

  • StarterCharacterScripts

  • StarterPlayerScripts

  • PlayerGui

  • A player's character

  • ReplicatedFirst

  • The upcoming ReplicatedScriptService

  1. The first parameter on the OnServerEvent event is the player who fired it. Also, I assume you were using "Print" as an argument.

  2. ServerScripts don't run on LocalScript's, or RemoteEvents. They only run on the following:

  • Workspace.

  • ServerScriptService

  • The upcoming ReplicatedScriptService

Solutions:

  1. Place the LocalScript in StarterPlayerScripts.

  2. Place the ServerScript in ServerScriptService.

  3. Place the RemoteEvent in ReplicatedStorage. Make sure the RemoteEvent is an actual RemoteEvent, not a RemoteFunction.

Recommendations:

  1. Use UserInputService as Mouse.KeyDown is deprecated.

  2. Put local before declaring a variable.

  3. You do not need variables that you do not use. They waste memory.

Fixed Script:

local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
       game.Replicated.RemoteEvent:FireServer("2")
        print("1")
    end
end)

--Server

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, message)
        print(message)

end)

Please accept this answer if it helped!

0
I cannot appreciate you enough. Thank you. Storche 13 — 4y
0
No problem. youtubemasterWOW 2741 — 4y
Ad

Answer this question