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

Why is this local script not executing in a server?

So I'm trying to make a character selection thing, but it's not working. It works perfectly in studio, but not in a server.

Server Script:

function Events.CharacterChange.OnServerInvoke(plr, class)
    local char = game.ReplicatedStorage.Characters:findFirstChild(class["Name"]):Clone()
    char.Parent = workspace
    char.Name = plr.Name
    char:FindFirstChild("Health").Disabled = false
    char:FindFirstChild("Sound").Disabled = false
    plr.Character = char
    return true
end

Local Script

script.Parent.Select.MouseButton1Click:connect(function()
    script.Parent.Select.Visible = false
    local chart = Events.CharacterChange:InvokeServer(Characters[index])
    repeat wait() until chart
    print("char")
    local char = game.Players.LocalPlayer.Character
    char:FindFirstChild("Animate").Disabled = false
    workspace.CurrentCamera.CameraType = "Custom"
    workspace.CurrentCamera.CameraSubject = char.Humanoid
    workspace.CurrentCamera.CFrame = char.HumanoidRootPart.CFrame
end)

It prints 'char' in studio, but it doesn't print anything in a server. The camera subject remains a part in workspace, and the camera type is still Scriptable. Also the animation script doesn't execute in a server, but in studio. No errors, the output is clean. The server script executes, so the problem is with the local script.

1 answer

The reason char is not being printed in game is because you are printing char on the client. In game you could use the developer console to see the client logs also in studio when running servers the player tab will have the client logs. Also on line 7 of the localscript you are only change that on the client, remember that with filteringenabled on, changes made by the client will not pass over to the server, so you should use a remoteevent to change anything that is out of that certain script's reach.

3 comments

0
  1. I do know that it's printing on the client, that was the point. It wasn't printing anything.
0
  1. LocalScripts are client-sided. You can disable them with another localscript.
0

Well yea on the client if your going for that. It won't print on the server because you're doing that on the client. is the problem you don't know what the problem is? is it invoking from the server?

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