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

Script won't control everyone's camera?

Hello. I'm making a game where there's a voting system. When the voting is done, everyone's camera should be placed back to normal. But it doesn't even do that. (There are no error outputs.) I'm using a BindableEvent to get in contact with a LocalScript from a regular script. Here's my following scripts:

Fire BinEvent: (Regular Script in StarterGUI)

local remEvent = game.ReplicatedStorage.Remotes:WaitForChild("RemoteEvent")
local remEvent2 = game.ReplicatedStorage.Remotes:WaitForChild("RemoteEvent2")
local remEvent3 = game.ReplicatedStorage.Remotes:WaitForChild("RemoteEvent3")
local binEvent = game.ReplicatedStorage.Bindables:WaitForChild("Event")
local val = script.Parent.votin.votes.votesgiven
local val2 = script.Parent.votin.timeleft.decreasing
local gui = script.Parent

remEvent2.OnServerEvent:Connect(function()
	script.Parent.votin.timeleft.Text = "15"
	wait(1)
	script.Parent.votin.timeleft.Text = "14"
	wait(1)
	script.Parent.votin.timeleft.Text = "13"
	wait(1)
	script.Parent.votin.timeleft.Text = "12"
	wait(1)
	script.Parent.votin.timeleft.Text = "11"
	wait(1)
	script.Parent.votin.timeleft.Text = "10"
	wait(1)
	script.Parent.votin.timeleft.Text = "9"
	wait(1)
	script.Parent.votin.timeleft.Text = "8"
	wait(1)
	script.Parent.votin.timeleft.Text = "7"
	wait(1)
	script.Parent.votin.timeleft.Text = "6"
	wait(1)
	script.Parent.votin.timeleft.Text = "5"
	wait(1)
	script.Parent.votin.timeleft.Text = "4"
	wait(1)
	script.Parent.votin.timeleft.Text = "3"
	wait(1)
	script.Parent.votin.timeleft.Text = "2"
	wait(1)
	script.Parent.votin.timeleft.Text = "1"
	wait(1)
	script.Parent.votin.timeleft.Text = "0"
	wait(0.1)
	script.Parent.votin.notifier.Visible = true
	wait(3)
	binEvent:Fire()
end)

Receive fire (LocalScript In StarterPlayerScripts)

local binEvent = game.ReplicatedStorage.Bindables:WaitForChild("Event")
local camera = workspace.CurrentCamera

binEvent.Event:Connect(function()
	camera.CameraType = Enum.CameraType.Custom
end)

Any working answer is appreciated.

2 comments

0

Hey, aren't bindable events only restricted to communication between server scripts and other server scripts?

0

Also, I'd suggest using a for loop for that timeleft thing. It is really simple to use, and it really pays off once you learn how to use it.

2 answers

✓ Accepted answer

as RAFA1608 has stated, BindableEvents are for communicating from server script to server script. You should use a remote event and use FireAllClients instead of bin event and Fire.

and also replace Event event with OnClientEvent

1 comment

0

the api reference also states: BindableEvents do not allow for communication between the server and client. If you are looking for this functionality use RemoteEvent.

sorry if comments are not useful english is not my first language

LOCALscript in startergui (do not use server script in startergui)

local ReplicatedStorage = game:GetService "ReplicatedStorage"
local RemoteEvents = {
	ReplicatedStorage.Remotes.RemoteEvent;
	ReplicatedStorage.Remotes.RemoteEvent2; -- [[ Change these to bindable events OR Change bindable to remote and make this server script again. ]]
	ReplicatedStorage.Remotes.RemoteEvent3;
}
local Bindable = ReplicatedStorage.Bindables.Event

local Gui = script.Parent

local votesgiven = Gui:WaitForChild("votin"):WaitForChild("votes"):WaitForChild("votesgiven")\
local notifier = Gui.votin.notifier
local timeleft = Gui.votin.timeleft
local decreasing = timeleft:WaitForChild("decreasing")

RemoteEvents.OnServerEvent--[[ Change this too if you change the remote events ]]:Connect(function()
	for i = 15, 0, -1 do
		timeleft.Text = tostring(i)
		wait(1)
	end
	
	wait(0.1)
	
	notifier.Visible = true
	wait(3)
	Bindable:Fire()--[[ Change if you change bindable ]]
end)

other script

local ReplicatedStorage = game:GetService "ReplicatedStorage"
local Bindable = ReplicatedStorage.Bindables.Event
local Camera = workspace.CurrentCamera

Bindable.Event--[[ Change if you changed the bindable ]]:Connect(function()
	Camera.CameraType = Enum.CameraType.Custom
end)

2 comments

0

I get an error. "OnServerEvent" can only be used on the server.

0

Thank you!

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