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

Help with server event, doesn't work when I start the server?

Asked by 6 years ago
Edited 6 years ago

This works in studio but when I press start server only the 1st event works

Local Script

local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("CeroEvent")
Userinputservice = game:GetService("UserInputService")
local RemoteEvent2 = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("CeroEvent2")
charging = false

Userinputservice.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.C then
        print("The C key was pressed!")
        charging = true     
        RemoteEvent:FireServer(nil)
    end
end)

Userinputservice.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.C and charging then
        charging = false
        print("Does it get here?") --It prints both in studio and server
        RemoteEvent2:FireServer(nil)
    end
end)

Script

local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("CeroEvent")
local RemoteEvent2 = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("CeroEvent2")
Power = true
Size = 10

RemoteEvent.OnServerEvent:Connect(function(player)
    --Stuff...Works both in server and studio, doesn't influence the other event besides that some parts from there are CFramed after one from here, the part is global not local so shouldn't be a problem.
end)

RemoteEvent2.OnServerEvent:Connect(function(player)
    print("Does it get here then?")--Doesn't print in server
    --Stuff down here but since I've got no error and doesn't print^ shouldn't be a problem
end)

Thank you!

0
What's your problem.... NetworkEngineer 0 — 6y

Answer this question