I have a system of luck boost and inventory and if the player has more than the player can store in his inventory that do nothing, but idk how can I update the value
The value read in the script is the value when I loggin into the game and not the value when Im playing and when it is beeing changed
task.wait(4)
local LPlayer = game.Players.LocalPlayer
local RS = game:GetService("ReplicatedStorage")
local CollF = workspace.Collectibles
local BoostCount = LPlayer.BoostCount.Value
local PopUpFrame = LPlayer.PlayerGui:WaitForChild("PopUpGUI"):WaitForChild("MainFrame")
local PopUpText = PopUpFrame:WaitForChild("MainLabel")
local function trigger(instance, spawnLocation)
local main = instance.Parent
instance.Triggered:Connect(function(plr)
local BoostF = plr.Boosts
if BoostF then
local potion = BoostF:FindFirstChild(main.Name)
if potion then
local luckboost = plr.LuckBoostTaken:FindFirstChild(spawnLocation)
if luckboost then
if BoostCount <= 0 then
RS.Remotes.BoostNotTaken:FireServer(potion, luckboost)
RS.Remotes.StoreBoost:FireServer(potion.Name)
main:Destroy()
print(BoostCount)
elseif BoostCount >= plr.MaxBoost.Value then
PopUpText.Text = "You've reached the max amount of boost !"
PopUpText:TweenPosition(UDim2.new(0,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.35, true)
wait(1.55)
PopUpText:TweenPosition(UDim2.new(0,0,1,0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.35, true)
return
end
end
end
end
end)
end
for _, part in pairs(CollF:GetChildren()) do
local prompt = part:FindFirstChild("ProximityPrompt")
if prompt then
trigger(prompt, part.Spawnpoint.Value)
end
end
task.wait(4)
local LPlayer = game.Players.LocalPlayer
local RS = game:GetService("ReplicatedStorage")
local CollF = workspace.Collectibles
local BoostCount = LPlayer.BoostCount
local PopUpFrame = LPlayer.PlayerGui:WaitForChild("PopUpGUI"):WaitForChild("MainFrame")
local PopUpText = PopUpFrame:WaitForChild("MainLabel")
local function trigger(instance, spawnLocation)
local main = instance.Parent
instance.Triggered:Connect(function(plr)
local BoostF = plr.Boosts
if BoostF then
local potion = BoostF:FindFirstChild(main.Name)
if potion then
local luckboost = plr.LuckBoostTaken:FindFirstChild(spawnLocation)
if luckboost then
if BoostCount.Value <= 0 then
RS.Remotes.BoostNotTaken:FireServer(potion, luckboost)
RS.Remotes.StoreBoost:FireServer(potion.Name)
main:Destroy()
print(BoostCount)
elseif BoostCount.Value >= plr.MaxBoost.Value then
PopUpText.Text = "You've reached the max amount of boost !"
PopUpText:TweenPosition(UDim2.new(0,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.35, true)
wait(1.55)
PopUpText:TweenPosition(UDim2.new(0,0,1,0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.35, true)
return
end
end
end
end
end)
end
for _, part in pairs(CollF:GetChildren()) do
local prompt = part:FindFirstChild("ProximityPrompt")
if prompt then
trigger(prompt, part.Spawnpoint.Value)
end
end