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

Script sends to server but not client?

Asked by 7 years ago
Edited 7 years ago

I've been working on this script and have been trying to figure out why its not working when I start the actual multiplayer version. It works in the Studio but not solo. I read that you can use F7 to test it while being able to see the console. When i click on the object it sends the print message to the console for the server but doesn't send it on the client console. I've tried to change the script to a local script and had no luck. I've used F9 and saw no errors. What am I missing? Also this script is connected to a server side object(npc) so local scripts shouldn't be the problem.

function onClicked()
    print("Clicked")
    if(_G.Quest1 == 0) then
        if(game.Players.LocalPlayer.PlayerGui.ScreenGui.Quest1NotAccepted.Visible == true) then
            game.Players.LocalPlayer.PlayerGui.ScreenGui.Quest1NotAccepted.Visible = false
        else
            game.Players.LocalPlayer.PlayerGui.ScreenGui.Quest1NotAccepted.Visible = true
        end
    end

    if(_G.Quest1 == 1) then
        if(game.Players.LocalPlayer.PlayerGui.ScreenGui.Quest1Accepted.Visible == true) then
            game.Players.LocalPlayer.PlayerGui.ScreenGui.Quest1Accepted.Visible = false
        else
            game.Players.LocalPlayer.PlayerGui.ScreenGui.Quest1Accepted.Visible = true
        end
    end

    if(_G.Quest1 == 2) then
        if(game.Players.LocalPlayer.PlayerGui.ScreenGui.Quest1Complete.Visible == true) then
            game.Players.LocalPlayer.PlayerGui.ScreenGui.Quest1Complete.Visible = false
        else
            game.Players.LocalPlayer.PlayerGui.ScreenGui.Quest1Complete.Visible = true
        end
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

Log in to vote
0
Answered by 7 years ago

You cannot use LocalPlayer in a server script. You can only use it in a LocalScript. It works in Studio because it doesn't have any differentiation between the server and the client.

Ad

Answer this question