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

Do you use remote events or functions in a script?

Just wondering, getting back into LUA after a billion years to be honest.

I was making this thing where there's a bar on the players screens and it constantly updates and if the StringValue changed then the text did to, so I went into an actual server on my testing game and tried it and it didn't work, I also did it with remote events but it gave me an error, and I completely forgot what functions were.

Anyways, I really need help with that, here is the local script for the bar. (Located in the PlayerGui when joined)

while true do
	wait(0.01)
	
	script.Parent.Bar.Frame.TextLabel.Text = game.ReplicatedStorage.Bar.Announce.Value
	
	if game.ReplicatedStorage.Bar.RemoveWeapons.Value == true then
		game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
	else
		game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
	end
end

And here is the bar value changing script that's located in ServerScriptService

script.RemoteEvent.OnServerEvent:connect(function(player,text)
	game.ReplicatedStorage.Bar.Announce.Value = text
end)

while true do
	wait(2)
	script.RemoteEvent:FireServer("This game is being worked on")
	game.ReplicatedStorage.Bar.Announce.Value = "This game is being worked on"
	wait(2)
	script.RemoteEvent:FireServer(
		"Please come back later"
	)
	game.ReplicatedStorage.Bar.Announce.Value = "Please come back later"
end

P.S. I know I put the RemoteEvent in the script, I just tried to test it. I also put it in the ReplicatedStorage thing and it still didn't work; gives an error.

Anyways, if you can help me then thanks :)

2 answers

✓ Accepted answer

maybe local. Try copy and pasting code for local scripts. Maybe inspect the code?

1 comment

0

Well, I wouldn't want to run the code of everyone's things and then change it multiple times, depending on their internet, it may slow down the text and keep changing back to the old one again.

The reason your script isn't working is simply because you cannot do :FireServer() from a server script. (You might have a local script there if so Im wrong but Im just assuming) I would have it where you have a ServerScript in ServerScriptService and havea local script checking. Which when it changes it Does :FireServer() from the local script in somewhere like ReplicatedStorage. Then you can have the server script waiting for the EVent to be fired which can change the text.

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