I’m trying to make an effect for when someone is touching a part, by making the fog and ambient in Lighting have different values, however if one person touches this part, the effect plays for everyone in the server.
The script is located in StarterPlayerScripts, and uses a 2nd script and a BindableEvent both parented to the same script.
I’ve tried switching the original script location somewhere like StarterGui but the effect keeps playing for everyone.
Scripts:
Script 1 (main script for the effect)
local Music = workspace.Music:GetChildren() -- normal game music
local otherMusic = workspace.OtherMusic
local currentSong = game.ReplicatedStorage.CurrentSong
local randSound = nil
local prevSound = nil
local in700m = false
script["700m"].Event:Connect(function(bool)
in700m = bool
if in700m then
for i, v in pairs(workspace.Music:GetChildren()) do
v.Volume = 0 -- muting normal music
end
game.Lighting.FogColor = Color3.fromRGB(255, 85, 0)
game.Lighting.FogEnd = 150
game.Lighting.ClockTime = 0
game.Lighting.OutdoorAmbient = Color3.fromRGB(255, 0, 0)
otherMusic["700mMusic"]:Play()
else
for i, v in pairs(workspace.Music:GetChildren()) do
v.Volume = 1 -- unmuting normal music
end
game.Lighting.FogColor = Color3.fromRGB(255, 255, 255)
game.Lighting.FogEnd = 500
game.Lighting.ClockTime = 14.5
game.Lighting.OutdoorAmbient = Color3.fromRGB(70,70,70)
otherMusic["700mMusic"]:Stop()
end
end)
Script 2 (detecting when the player touches the hitbox)
local region = workspace["700mRegion"]
local event = script.Parent["700m"]
region.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
event:Fire(true)
end
end)
region.TouchEnded:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
event:Fire(false)
end
end)