Right now I am attempting to make an ability that darkens and fogs up the screen of everyone in the server except players with the vampire role, and the ability user. I wrote up 2 scripts using bindableEvents. When the player presses a key, a local script sends an event that then fires the bindableEvent, Then a localscript placed inside all players will fog up the effected players game accordingly. The problem is, the serverscript is not firing the event correctly. I don't get any errors for it, when I fire the event through the localscript, it fires when players spawn in. If there is an alternative to this method, or a way to fix it, any help would be appreciated.
Heres the serverscript firing the event:
local BeastEvent = game.ReplicatedStorage.Events.Nightfall
local bindableEvent = game.ReplicatedStorage.Events:WaitForChild("Nightfell")
BeastEvent.OnServerEvent:Connect(function(player)
for _, player4 in ipairs(game.Players:GetPlayers()) do
bindableEvent:Fire(player4)
end
end)
And the localscript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local bindableEvent = ReplicatedStorage.Events:WaitForChild("Nightfell")
local char = script.Parent
local function OnEvent(player)
if player.Character.charactervalues.Role.Value ~= "Vampire" then
print("heya") --> Hello, world!
end
end
bindableEvent.Event:Connect(OnEvent)

1 comment
I didn't know you could fire to all clients. This helped alot, thanks!