Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Misc settings fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pluviolithic committed Nov 30, 2023
1 parent bfe8fd1 commit dad2642
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 38 deletions.
34 changes: 19 additions & 15 deletions src/client/Pets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local petsFolder = workspace.PetModels
local playerName = Players.LocalPlayer.Name

local function setPetEnabled(pet, enabled)
pet.PetUI.Enabled = enabled
pet:WaitForChild("PetUI").Enabled = enabled
for _, part in pet:GetChildren() do
if part:IsA "BasePart" then
part.Transparency = if enabled then 0 else 1
Expand All @@ -27,7 +27,7 @@ local function updateMyPets(show)
end

for _, pet in playerPetFolder:GetChildren() do
setPetEnabled(pet, show)
task.spawn(setPetEnabled, pet, show)
end
end
end
Expand All @@ -39,25 +39,29 @@ local function updateOtherPets(show)
end

for _, pet in playerPetFolder:GetChildren() do
setPetEnabled(pet, show)
task.spawn(setPetEnabled, pet, show)
end
end
end

petsFolder.DescendantAdded:Connect(function(descendant)
if not descendant:FindFirstChild "PetUI" then
return
end

if descendant.Parent.Name == playerName then
if not selectors.getSetting(store:getState(), playerName, "ShowMyPets") then
setPetEnabled(descendant, false)
end
return
local function handleSubPetFolder(subPetFolder)
if subPetFolder.Name == playerName then
updateMyPets(selectors.getSetting(store:getState(), playerName, "ShowMyPets"))
subPetFolder.ChildAdded:Connect(function()
updateMyPets(selectors.getSetting(store:getState(), playerName, "ShowMyPets"))
end)
else
updateOtherPets(selectors.getSetting(store:getState(), playerName, "ShowOtherPets"))
subPetFolder.ChildAdded:Connect(function()
updateOtherPets(selectors.getSetting(store:getState(), playerName, "ShowOtherPets"))
end)
end
end

if not selectors.getSetting(store:getState(), descendant.Parent.Name, "ShowOtherPets") then
setPetEnabled(descendant, false)
petsFolder.ChildAdded:Connect(handleSubPetFolder)
task.spawn(function()
for _, player in Players:GetPlayers() do
handleSubPetFolder(petsFolder:WaitForChild(player.Name))
end
end)

Expand Down
3 changes: 3 additions & 0 deletions src/client/UI/CodesUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ local ReplicatedStorage = game:GetService "ReplicatedStorage"

local Remotes = require(ReplicatedStorage.Common.Remotes)
local CentralUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.CentralUI)
local interfaces = require(StarterPlayer.StarterPlayerScripts.Client.UI.CollidableInterfaces)

local player = Players.LocalPlayer
local CodesUI = CentralUI.new(player.PlayerGui:WaitForChild "Codes")

function CodesUI:_initialize()
interfaces[self] = true

player.PlayerGui:WaitForChild("MainUI").Codes.Activated:Connect(function()
self:setEnabled(not self._isOpen)
end)
Expand Down
5 changes: 5 additions & 0 deletions src/client/UI/SettingsUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local Remotes = require(ReplicatedStorage.Common.Remotes)
local selectors = require(ReplicatedStorage.Common.State.selectors)
local store = require(StarterPlayer.StarterPlayerScripts.Client.State.Store)
local CentralUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.CentralUI)
local interfaces = require(StarterPlayer.StarterPlayerScripts.Client.UI.CollidableInterfaces)
local playerStatePromise = require(StarterPlayer.StarterPlayerScripts.Client.State.PlayerStatePromise)

local gamepassIDs = ReplicatedStorage.Config.GamepassData.IDs
Expand All @@ -17,9 +18,13 @@ local SettingsUI = CentralUI.new(player.PlayerGui:WaitForChild "Settings")
local function shouldRefresh(newState, oldState)
return selectors.getTempSettings(newState, player.Name) ~= selectors.getTempSettings(oldState, player.Name)
or selectors.getSavedSettings(newState, player.Name) ~= selectors.getSavedSettings(oldState, player.Name)
or selectors.hasGamepass(newState, player.Name, "2xSpeed")
and not selectors.hasGamepass(oldState, player.Name, "2xSpeed")
end

function SettingsUI:_initialize(): ()
interfaces[self] = true

for _, settingSwitch in self._ui.Background.ScrollingFrame:GetChildren() do
if not settingSwitch:FindFirstChild "On" then
continue
Expand Down
3 changes: 3 additions & 0 deletions src/client/UI/Shops/RobuxShop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local rankUtils = require(ReplicatedStorage.Common.Utils.RankUtils)
local selectors = require(ReplicatedStorage.Common.State.selectors)
local store = require(StarterPlayer.StarterPlayerScripts.Client.State.Store)
local CentralUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.CentralUI)
local interfaces = require(StarterPlayer.StarterPlayerScripts.Client.UI.CollidableInterfaces)
local playerStatePromise = require(StarterPlayer.StarterPlayerScripts.Client.State.PlayerStatePromise)

local gamepassIDs = ReplicatedStorage.Config.GamepassData.IDs
Expand Down Expand Up @@ -91,6 +92,8 @@ function RobuxShop:_countdownDescriptionDisplayTime()
end

function RobuxShop:_initialize(): ()
interfaces[self] = true

mainUI.RobuxShop.Activated:Connect(function()
self:setEnabled(not self._isOpen)
end)
Expand Down
55 changes: 34 additions & 21 deletions src/server/Combat/FearEffects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,43 @@ end

local defaultWalkSpeed = 14
local walkSpeedFearDebuff = -4

local function updatePlayerFearEffects(player, newState, oldState)
local hasDoubleSpeed = selectors.hasGamepass(newState, player.Name, "2xSpeed")
and selectors.getSetting(newState, player.Name, "2xSpeed")
local modifiedDebuff = walkSpeedFearDebuff * (hasDoubleSpeed and 2 or 1)
local newWalkSpeed = defaultWalkSpeed * (hasDoubleSpeed and 2 or 1)
if isScared(player.Name, newState) then
task.spawn(trackPlayerScaredStatus, player)
newWalkSpeed += modifiedDebuff
elseif oldState and isScared(player.Name, oldState) then
newWalkSpeed -= modifiedDebuff
end
local humanoid = if player.Character then player.Character:FindFirstChild "Humanoid" else nil
if humanoid and humanoid.WalkSpeed ~= newWalkSpeed then
humanoid.WalkSpeed = newWalkSpeed
end
if
oldState
and selectors.isPlayerLoaded(oldState, player.Name)
and selectors.hasGamepass(newState, player.Name, "2xFearMeter")
and not selectors.hasGamepass(oldState, player.Name, "2xFearMeter")
then
store:dispatch(actions.setPlayerStat(player.Name, "CurrentFearMeter", 0))
end
end

store.changed:connect(function(newState, oldState)
for _, player in Players:GetPlayers() do
local hasDoubleSpeed = selectors.hasGamepass(newState, player.Name, "2xSpeed")
and selectors.getSetting(newState, player.Name, "2xSpeed")
local modifiedDebuff = walkSpeedFearDebuff * (hasDoubleSpeed and 2 or 1)
local newWalkSpeed = defaultWalkSpeed * (hasDoubleSpeed and 2 or 1)
if isScared(player.Name, newState) then
task.spawn(trackPlayerScaredStatus, player)
newWalkSpeed += modifiedDebuff
elseif isScared(player.Name, oldState) then
newWalkSpeed -= modifiedDebuff
end
local humanoid = if player.Character then player.Character:FindFirstChild "Humanoid" else nil
if humanoid and humanoid.WalkSpeed ~= newWalkSpeed then
humanoid.WalkSpeed = newWalkSpeed
end
if
selectors.isPlayerLoaded(oldState, player.Name)
and selectors.hasGamepass(newState, player.Name, "2xFearMeter")
and not selectors.hasGamepass(oldState, player.Name, "2xFearMeter")
then
store:dispatch(actions.setPlayerStat(player.Name, "CurrentFearMeter", 0))
end
updatePlayerFearEffects(player, newState, oldState)
end
end)

Players.PlayerAdded:Connect(function(player: Player)
repeat
task.wait(0.5)
until selectors.isPlayerLoaded(store:getState(), player.Name)
updatePlayerFearEffects(player, store:getState())
end)

return 0
11 changes: 9 additions & 2 deletions src/server/PlayerManager/PlayerStatusUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@ function PlayerStatusUI:_updateUIFields(state)
selectors.hasGamepass(state, self._player.Name, "VIP")
and selectors.getSetting(state, self._player.Name, "VipNameTag")
then
self._player:SetAttribute("isVIP", true)
playerUIFrame.PlayerName.TextColor3 = Color3.fromRGB(255, 193, 7)
else
self._player:SetAttribute("isVIP", false)
playerUIFrame.PlayerName.TextColor3 = Color3.fromRGB(255, 255, 255)
end

if
selectors.hasGamepass(state, self._player.Name, "VIP")
and selectors.getSetting(state, self._player.Name, "VipChatTag")
then
self._player:SetAttribute("isVIP", true)
else
self._player:SetAttribute("isVIP", false)
end
end

function PlayerStatusUI:_applyUI(character: Model)
Expand Down

0 comments on commit dad2642

Please sign in to comment.