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

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

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.

9 comments

0

and just what is the food gui?

0

also, FireAllClients doesn't need a play parameter, and the localplayer is nil of the server

0

The food gui is located inside a NPC, within the workspace that has four food choices.

0

Bump.

0

Bump!

0

Try having it in ServerScriptService. Personally I've had no issues with FireAllClients, but every time i've used it was from ServerScriptService.

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

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.

1 answer

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

1 comment

0

Solved.

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