Hey there. I am currently trying to make LocalScript and ServerScript communicate with each other. Now, this Script worked before, made no changes on it and so on. (Just advnaced the script, but nothing has to do with the problem)
It should print ("Worked!"), but it doesnt. Even tho the :FireServer worked.
LocalScript:
game.Players.LocalPlayer.PlayerGui.Dialog.Frame.Text.Text = "Lets go!"
wait(2)
print("Firing Server") --prints
game.ReplicatedStorage.Dialogg18:FireServer()
print("Fired Server") --prints
end
And the ServerScript:
local function Func()
print("Got Event")
local isnil
local NumberD2 = 0
local NewNameF
local NewNameP
local UserCountIdk = workspace.AllPlayer:GetChildren()
for i, user in ipairs(UserCountIdk) do
repeat
NumberD2 = NumberD2 + 1
NewNameF = "User" .. NumberD2
NewNameP = workspace.AllPlayer:FindFirstChild(NewNameF).Value
wait(0.1)
if nil then
print("yes")
isnil = true
else
print("not nil")
isnil = false
end
until isnil == false
game.ReplicatedStorage.Dialogg4:FireClient(game.Players:FindFirstChild(NewNameP))
print("Worked!")
end
end
NumberD2 = 0
game.ReplicatedStorage.Dialogg18.OnServerEvent:Connect(Func)

7 comments
workspace.AllPlayer? if you want to get the players you should use game.Players:GetChildren(), or maybe im missing something
workspace.AllPlayer has all the Players that are currently in the game. If they die or lose a minigame, their stringvalue gets deleted.
and it prints "yes", or "not nil"? also, in every script ive made ive always used FindFirstChild() with " or ' when im having it search for something, though ive only used blank variables like your local NewNameF to define what it is before hand, or right after like a data save system
It prints "not nil".
Make sure
game.ReplicatedStorage.Dialogg18.OnServerEvent:Connect(Func)is outside of the function.It is.
Make sure the spelling is correct and I don’t know if you can call models/guis numbers try it with words only.