well i want the script to work in live servers, everything works fully functional but isn’t working on live?
the issue is this script works and all but when i go into live server it will not let me spend points on anything at all nothing works and i get no errors or anything?
idk i tried a lot of different ways methods ways it works and such and nothing works i can’t seem to figure out the problem?
-- local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpendPointsEvent = ReplicatedStorage.SpendPointsEvent
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local pointsValue = leaderstats:WaitForChild("Points")
local walkspeedValue = leaderstats:WaitForChild("Walkspeed")
local damageValue = leaderstats:WaitForChild("Damage")
local healthValue = leaderstats:WaitForChild("Health")
local WalkspeedButton = script.Parent.WalkspeedButton
local DamageButton = script.Parent.DamageButton
local HealthButton = script.Parent.HealthButton
local PointStats = script.Parent.PointStats
local WalkSpeedStat = script.Parent.WalkSpeedStat
local DamageStats = script.Parent.DamageStats
local HealthStat = script.Parent.HealthStat
-- Customizations
local PointsRequired = 1
local maxWalkspeedPoints = 60
local maxDamagePoints = 500
local maxHealthPoints = 10000
local function updatePointsDisplay(points)
PointStats.Text = "Points: " .. points
end
local function updateWalkspeedDisplay()
WalkSpeedStat.Text = "Walkspeed: " .. walkspeedValue.Value
end
local function updateDamageDisplay()
DamageStats.Text = "Damage: " .. damageValue.Value
end
local function updateHealthDisplay()
HealthStat.Text = "Health: " .. healthValue.Value
end
local function increaseWalkspeed()
if pointsValue.Value >= PointsRequired and walkspeedValue.Value < maxWalkspeedPoints then
SpendPointsEvent:FireServer(PointsRequired, "Walkspeed")
else
print("Insufficient points or Walkspeed already maxed!")
end
end
local function increaseDamage()
if pointsValue.Value >= PointsRequired and damageValue.Value < maxDamagePoints then
SpendPointsEvent:FireServer(PointsRequired, "Damage")
else
print("Insufficient points or Damage already maxed!")
end
end
local function increaseHealth()
if pointsValue.Value >= PointsRequired and healthValue.Value < maxHealthPoints then
SpendPointsEvent:FireServer(PointsRequired, "Health")
else
print("Insufficient points or Health already maxed!")
end
end
updatePointsDisplay(pointsValue.Value)
updateWalkspeedDisplay()
updateDamageDisplay()
updateHealthDisplay()
ReplicatedStorage.PointsChangedEvent.OnClientEvent:Connect(function(points)
updatePointsDisplay(points)
end)
-- Add event connections to update GUI and leaderstats when changes occur
walkspeedValue.Changed:Connect(updateWalkspeedDisplay)
damageValue.Changed:Connect(updateDamageDisplay)
healthValue.Changed:Connect(updateHealthDisplay)
WalkspeedButton.MouseButton1Click:Connect(function()
increaseWalkspeed()
end)
DamageButton.MouseButton1Click:Connect(function()
increaseDamage()
end)
HealthButton.MouseButton1Click:Connect(function()
increaseHealth()
end)
not really sure but it could be that the player didnt load properly causing yielding/errors. try to press f9 to pull out the console and see whats going on in an live game and also try to load the game by waiting until its loaded in the top of script
ok so i’m using an old script here, this is the version that did work on live servers, the one in post does not but why?
local SpendPointsEvent = ReplicatedStorage.SpendPointsEvent
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local pointsValue = leaderstats:WaitForChild("Points")
local walkspeedValue = leaderstats:WaitForChild("Walkspeed")
local damageValue = leaderstats:WaitForChild("Damage")
local healthValue = leaderstats:WaitForChild("Health") -- Add support for the Health stat
local WalkspeedButton = script.Parent.WalkspeedButton
local DamageButton = script.Parent.DamageButton
local HealthButton = script.Parent.HealthButton -- Add support for the Health button
local PointStats = script.Parent.PointStats
local WalkSpeedStat = script.Parent.WalkSpeedStat
local DamageStats = script.Parent.DamageStats
local HealthStat = script.Parent.HealthStat -- Add support for the Health stat display
--Customizations--
local PointsRequired = 1
local maxWalkspeedPoints = 60
local maxDamagePoints = 500
local maxHealthPoints = 10000 -- Set maximum health points
local function updatePointsDisplay(points)
PointStats.Text = "Points: " .. points
end
local function updateWalkspeedDisplay()
WalkSpeedStat.Text = "Walkspeed: " .. walkspeedValue.Value
end
local function updateDamageDisplay()
DamageStats.Text = "Damage: " .. damageValue.Value
end
local function updateHealthDisplay()
HealthStat.Text = "Health: " .. healthValue.Value -- Display Health value from leaderstats
end
local function increaseWalkspeed()
if pointsValue.Value >= PointsRequired and walkspeedValue.Value < maxWalkspeedPoints then
SpendPointsEvent:FireServer(PointsRequired, "Walkspeed") -- Call the server-side event to spend points for Walkspeed
else
print("Insufficient points or Walkspeed already maxed!")
end
end
local function increaseDamage()
if pointsValue.Value >= PointsRequired and damageValue.Value < maxDamagePoints then
SpendPointsEvent:FireServer(PointsRequired, "Damage") -- Call the server-side event to spend points for Damage
else
print("Insufficient points or Damage already maxed!")
end
end
local function increaseHealth()
if pointsValue.Value >= PointsRequired and healthValue.Value < maxHealthPoints then
SpendPointsEvent:FireServer(PointsRequired, "Health") -- Call the server-side event to spend points for Health
else
print("Insufficient points or Health already maxed!")
end
end
-- Set the initial text of the DisplayPointsStat TextButton with the player's current points
updatePointsDisplay(pointsValue.Value)
updateWalkspeedDisplay()
updateDamageDisplay()
updateHealthDisplay() -- Update the initial Health display
-- Listen for the PointsChangedEvent to update the points on the client side
ReplicatedStorage.PointsChangedEvent.OnClientEvent:Connect(function(points)
updatePointsDisplay(points)
end)
WalkspeedButton.MouseButton1Click:Connect(function()
increaseWalkspeed()
updateWalkspeedDisplay()
end)
DamageButton.MouseButton1Click:Connect(function()
increaseDamage()
updateDamageDisplay()
end)
HealthButton.MouseButton1Click:Connect(function()
increaseHealth()
updateHealthDisplay()
end)