RemoteEvent not working

I’m trying to make a Gui appear depending on whether the players won or not, but nothing happens??
For some reason the Win and Lose events don’t work? I’m pretty sure they fire because there are no errors whatsoever, the localscripts just don’t work??
here’s the relevant chunk of the ServerScript:

game.ReplicatedStorage.Events.Start.Event:Connect(function(startgame)

	--respawn & reward players--
		for index, plr in pairs(players:GetPlayers()) do -- Gets all the players
		plr:LoadCharacter() -- Respawns them
			plr.Character:WaitForChild("HumanoidRootPart") -- Waiting for character to exist
			    plr:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")
				local points = plr:WaitForChild("leaderstats"):WaitForChild("Points")
				
			if FI.Value < 10 then
				
				game.ReplicatedStorage.Events.Win:FireAllClients()
				points.Value = points.Value + reward.Value * 10
				print("Winners")
				
			else
				
				game.ReplicatedStorage.Events.Lose:FireAllClients()
				print("Losers")
				
		end
	end

LocalScripts:

local Info = TweenInfo.new(1)
local Tween = game:GetService("TweenService"):Create(script.Parent,Info,{TextTransparency=0})
local Tween2 = game:GetService("TweenService"):Create(script.Parent,Info,{TextTransparency=1})

game.ReplicatedStorage.Events.Lose.OnClientEvent:Connect(function()
	script.Parent.Lose:Play()
	
Tween:Play()

wait(4.5)

Tween2:Play()

end)
local Info = TweenInfo.new(1)
local Tween = game:GetService("TweenService"):Create(script.Parent,Info,{TextTransparency=0})
local Tween2 = game:GetService("TweenService"):Create(script.Parent,Info,{TextTransparency=1})

game.ReplicatedStorage.Events.Win.OnClientEvent:Connect(function()
	script.Parent.Cheer:Play()
	
Tween:Play()

wait(4.5)

Tween2:Play()

end)

I’ve never been stumped on something seemingly so simple, I’ve tried just about everything I could think of the past few days.

Any and all help is appreciated, thanks in advance :+1:

3 Likes

Try putting prints in places, you think the code should get to, and then tell us the results.

For example, put a print("Win Event") in the win event.

Also, where is the local script located?

also put prints after these to make sure it ain’t yielding forever.

They’re in startergui and I have put prints, nothing prints in the localscripts

Alright so, whats wrong here is, the code runs one time when the round starts. For you to know when the “FI” value changes, you would have to do something like this:

FI:GetPropertyChangedSignal("Value"):Connect(function()
   if FI.Value <10 then
       game.ReplicatedStorage.Events.Win:FireAllClients()
       points.Value = points.Value + reward.Value * 10
       print("Winners")
   end
end)

The code you have right now, does not automatically work when the “FI” value changes or is updated, you would have to do it in that way ^

It does already get the accurate FI value, it gives the player the points and prints the accurate “Winners”/“Losers” print

It’s not yielding there, the script continues normally

Could you try putting the local script in StarterCharacterScripts?

I do not think that is the issue, it should still work. By the way @MCCREAP2, so printing anything in the local script does not work? (not talking about inside the remote event, but in general)

I would except there’s another Gui in the game with the exact same script that does run:

local Info = TweenInfo.new(1)
local Tween = game:GetService("TweenService"):Create(script.Parent,Info,{TextTransparency=0})
local Tween2 = game:GetService("TweenService"):Create(script.Parent,Info,{TextTransparency=1})

game.ReplicatedStorage.Events.RemoteAttack.OnClientEvent:Connect(function()
	
script.Parent.Reckless:Play()
	
Tween:Play()

wait(2.5)

Tween2:Play()

end)

This one works fine with the same script from StarterGui

You mean have I tried something like this?

print("Testing")

local Info = TweenInfo.new(1)
local Tween = game:GetService("TweenService"):Create(script.Parent,Info,{TextTransparency=0})
local Tween2 = game:GetService("TweenService"):Create(script.Parent,Info,{TextTransparency=1})

game.ReplicatedStorage.Events.Win.OnClientEvent:Connect(function()
	
	script.Parent.Cheer:Play()
	
Tween:Play()

wait(4.5)

Tween2:Play()

end)

Yes, does it work when you print anything outside the OnClientEvent?

Yes it does
h
h
h
h
h
h
(30char)

But the curveball here is that I have another Gui which does appear when I fire a RemoteEvent from the same script

I messed up something in the code it does appear to work, that is my bad. I’m unsure what could be causing your bug I think it’s something simple that were overlooking.

No worries! I appreciate you trying
You’re probably right about that but I feel like I’ve looked everywhere, this is about to drive me up the wall :man_facepalming:

Could it possibly be that the client event does not load fast enough for when the server event sends the signal? Where and when are you firing the start.event? Maybe try adding waits before you fire the events.

	if FI.Value < 10 then
				task.wait(2)
				game.ReplicatedStorage.Events.Win:FireAllClients()
				points.Value = points.Value + reward.Value * 10
				print("Winners")
				
			else
				task.wait(2)
				game.ReplicatedStorage.Events.Lose:FireAllClients()
				print("Losers")
				
		end
1 Like

Hm, I’m not sure, that’s a good question
I’m testing that right now

Adding task.wait() in the serverscript? I don’t get the point, I am 100% sure that the events are fired as they are located in ReplicatedStorage. The issue must be on the client side. I would highly recommend to wrap things up and just try using some other methods as the client does not seem to be catching up with the event.

IT WORKED thank you you are my hero

1 Like

No problem. Have a good day man.

1 Like