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

Firing client from a local scirpt help?

Asked by
NotSoNorm 777 Moderation Voter
8 years ago

I'm only doing this because I need to work around fe

error: 'FireClient can only be called from server Line 12'

I've tried a million times using everything I can to get this to work but to no avail.

--Sending/Reciving script

local Access = {"Adeleina","NotSoNorm","Player"}
local name = game.Players.LocalPlayer.Character.Name
local pos = "Inward"

if name == Access[1] or name == Access[2] or name == Access[3] then
    script.Parent.EditFrame.Visible = true
else
    script.Parent.EditFrame.Visible = false
end

script.Parent.EditFrame.Enter.MouseButton1Down:connect(function()
    game.Workspace.DisplayManger.Sender:FireClient(game.Players.LocalPlayer.Character, script.Parent.EditFrame.TextBox.Text)
end)

script.Parent.EditFrame.Hide.MouseButton1Down:connect(function()
    if pos == "Inward" then
        pos = "out"
        script.Parent.EditFrame.Hide.Text = "Hide"
        script.Parent.EditFrame:TweenPosition(UDim2.new(0, 0,0.4, 0),"InOut","Linear",.5,false)
        script.Parent.EditFrame.Hide:TweenPosition(UDim2.new(0,0,1.02,0),"InOut","Linear",.5, false)
    else
        pos = "Inward"
        script.Parent.EditFrame.Hide.Text = "Show"
        script.Parent.EditFrame:TweenPosition(UDim2.new(-.5, 0,0.4, 0),"InOut","Linear",.5,false)
        script.Parent.EditFrame.Hide:TweenPosition(UDim2.new(1.62,0,1.02,0),"InOut","Linear",.5, false)
    end
end)

game.Workspace.DisplayManger.Sender.OnClientEvent:connect(function(text)
    script.Parent.TextLabel.Text = "The party is at: "..text
end)

1 answer

Log in to vote
1
Answered by 8 years ago

You have FireClient mixed up. From a Client script, you need to use FireServer on the event, and receive that in the server via the OnServerEvent event. When trying to send info to the client, you need to use FireClient from a serverside script on the event, with the first variable being the Player instance. You can receive this via the OnClientEvent event in a clientside script (but the first variable is the second variable sent (so the player instance is not sent)).

If this is a serverside script, then you need to change "OnClientEvent" to "OnServerEvent", and if it's a clientside script, then you need to change "FireClient" to "FireServer".

Ad

Answer this question