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)
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)
GiveFood:FireAllClients(food,amount,player.Name)
return "Success"
end
GiveFoodRequest.OnServerInvoke = OnGiveFoodRequest
9 comments
and just what is the food gui?
also, FireAllClients doesn't need a play parameter, and the localplayer is nil of the server
The food gui is located inside a NPC, within the workspace that has four food choices.
https://gyazo.com/97aad288bb2296c20f24c391b33eb910
Bump.
Bump!
Try having it in ServerScriptService. Personally I've had no issues with FireAllClients, but every time i've used it was from ServerScriptService.
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
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.