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

FireAllCilents not working for Server?

Hey there,

I got this working on another Script but for this it doesn't seem to be working i get no Errors however not sure whats missing?

Server=

local host = workspace.Host
local myThread = coroutine.running()
workspace.Host.Touched:Connect(function(hit) 

if game.Players:GetPlayerFromCharacter(hit.Parent) then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)

function continueColorChange()
    coroutine.resume(myThread)
game.ReplicatedStorage.dialogTrigger:FireAllClients(player)

host.Touched:Connect(continueColorChange)
end
end
end)

LocalScript=

-- STAGE 2
local dialogGui = script.Parent
local object = script.Parent
local host = workspace.Host
local guiObject = script.Parent
local myThread = coroutine.running()

game.ReplicatedStorage.dialogTrigger.OnClientEvent:Connect(function()

-- Local type writer
function localTypeWriter(textElement, goal)
    for i=1, string.len(goal), 1 do
        textElement.Text = string.sub(goal,1,i)
        wait(-1.3)
    end
end

local function continueDialog()
    coroutine.resume(myThread)
end

host.Touched:Connect(continueDialog)
workspace.Host.Touched:Connect(function(hit) 
    if hit.Parent:findFirstChild("Humanoid") then 
        guiObject.Visible = true

        -- Require module
       
        --coroutine.yield()
       	
		coroutine.yield()
        localTypeWriter(script.Parent, "Head on over to the Potion Class!")
        wait(1)
        localTypeWriter(script.Parent, "Hello there students my name is Professor Herbert")
        wait(1)
        localTypeWriter(script.Parent, "Would you like to help me create my newest Potion?")
        wait(1)
        localTypeWriter(script.Parent, "Great! I’ll need the following ingredients..")
        wait(1)
        localTypeWriter(script.Parent, "They should all be hidden somewhere within the classes go look!")
        wait(1)
		localTypeWriter(script.Parent, "Make sure to return to me once you find them all!")
        wait(1)
		


        object.AnchorPoint = Vector2.new(0, 0)
        object.Position = UDim2.new{0, 0},{0, 0}


        object:TweenPosition(UDim2.new(0, 0, -10.04, 0), Enum.EasingDirection.In, Enum.EasingStyle.Sine,0.5)

        wait(2)

        script.parent.Visible = false
        if script.parent.Visible == false then 
            print("Worked2!")
		if hit.Parent:findFirstChild("Humanoid") then
			
		end
		host:Destroy()
        end
    end 
		end) 
			end)

Thanks,

2 comments

0

"FireAllClients" > Passes Player Argument

0

What does that mean exactly?, Sorry im new what would i have to change?

2 answers

FireAllClients fires every client in the game. Here it seems like you only want to fire the event for the player you have defined as player, so you'd just use :FireClient(player).

Soo this is pretty simple. It appears to be an issue on your server script.

Let's break your code down.

local host = workspace.Host
local myThread = coroutine.running()
workspace.Host.Touched:Connect(function(hit) 

if game.Players:GetPlayerFromCharacter(hit.Parent) then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)

function continueColorChange()
    coroutine.resume(myThread)
game.ReplicatedStorage.dialogTrigger:FireAllClients(player)

host.Touched:Connect(continueColorChange)
end
end
end)

Here to send stuff to the client you use: game.ReplicatedStorage.dialogTrigger:FireAllClients(player)

Do you want to send to ALL the clients (aka every player in game?). If so just use: game.ReplicatedStorage.dialogTrigger:FireAllClients()

If you want to send to a specific player, use: game.ReplicatedStorage.dialogTrigger:FireClient(player)

2 comments

0

I can understand that yes, Tried it out for all clients didn't seem to work?, Anything wrong in my LocalScript i need to change?

0

Doesn't appear so. Check it with a print("Test") at the top. If that fires, it's working and there is an issue in there.

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