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

Calling an Event not working in Server?

Asked by
iFlusters 355 Moderation Voter
8 years ago

I don't really see the issue with this, I've also tried disabling/enabling FilteringEnabled but that has no effect.

I have a LocalScript in StarterPlayerScripts, this is the script:

repeat wait() until game.Players.LocalPlayer
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Button1Event = ReplicatedStorage:WaitForChild("Button1Event")

Mouse.KeyDown:connect(function(key)
    if key == "e" then
        Button1Event:FireServer()
        print("Fired")
    end
end)

It calls an event once the player press 'e' that works fine in studio as it prints "Fired" successfully but it will not call it in a server, does anyone know why?

0
it might now work in server because it is stuck waiting on a child CarterTheHippo 120 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Try using a different code

local player = game.Players.LocalPlayer
repeat wait() until player.Character

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Button1Event = ReplicatedStorage:WaitForChild("Button1Event")


function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.E then
        Button1Event:FireServer()
            print("Fired")
    end
end)

game:GetService("UserInputService").InputBegan:connect(onKeyPress)
0
Nope doesn't work. iFlusters 355 — 8y
0
The code you've given me works fine in studio, but not in server, plus you don't need the bracket on the last end. iFlusters 355 — 8y
Ad

Answer this question