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

How would I go about FireallClients needing to be fired by the server?

Asked by 5 years ago

Hello, I'm wondering how I can go about with this "FireallClients", it's claiming that it needs to be fired by the server, but it's in a server script + in workspace located inside the food gui.

Code: https://hastebin.com/foyaruyani.bash

Thanks, Rook.

0
and just what is the food gui? theking48989987 2147 — 5y
0
also, FireAllClients doesn't need a play parameter, and the localplayer is nil of the server theking48989987 2147 — 5y
0
The food gui is located inside a NPC, within the workspace that has four food choices. User#26676 0 — 5y
View all comments (5 more)
0
Bump. User#26676 0 — 5y
0
Bump! User#26676 0 — 5y
0
Try having it in ServerScriptService. Personally I've had no issues with FireAllClients, but every time i've used it was from ServerScriptService. checkerscat2 116 — 5y
0
an easy way to tell if something in on the client or the server is with the IsServer and IsClient functions of the run service theking48989987 2147 — 5y
0
Judging from the video, gui is definitely local, as it only shows for one player. You will need a seperate remote function, asking the server to fire all clients. sleazel 1287 — 5y

1 answer

Log in to vote
0
Answered by
sleazel 1287 Moderation Voter
5 years ago

Try this:

script.Parent.MouseButton1Click:connect(function()
    local txt = "You want a taco? Alright, here you go."
    if script.Parent.Parent.Debounce.Value == false then
    script.Parent.Parent.Debounce.Value = true
for i = 1,#txt do
    script.Parent.Parent.Parent.CafeStuff.TextLabel.Text = string.sub(txt,1,i)
    wait(.01)
end
script.Parent.Parent.Money:play()
script.Parent.text.Text = "Sold!"

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GiveFoodRequest = ReplicatedStorage:WaitForChild("GiveFoodRequest")
local result = GiveFoodRequest:InvokeServer("Taco",3)
print(result) --delete later

wait(1)
script.Parent.text.Text = "Taco ($3)"
script.Parent.Parent.Debounce.Value = false
end
end)

And add this script to your ServerScriptStorage

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GiveFoodRequest = Instance.new("RemoteFunction")
GiveFoodRequest.Name = "GiveFoodRequest"
GiveFoodRequest.Parent = ReplicatedStorage
GiveFood = ReplicatedStorage:WaitForChild("GiveFood")

local function OnGiveFoodRequest(player,food,amount) --just guessing here
    GiveFood:FireAllClients(food,amount,player.Name)
    return "Success"
end

GiveFoodRequest.OnServerInvoke = OnGiveFoodRequest
0
Solved. User#26676 0 — 5y
Ad

Answer this question