You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make the player drop orbs when they die. -
What is the issue? Include screenshots / videos if possible!
The death function only runs one time. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried looking in the dev forums. I also tried modifying the script a bit.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Tiers = require(game.ReplicatedStorage.Tiers)
local OrbMod = require(game.ServerScriptService.Orb)
game.Players.PlayerAdded:Connect(function(plr)
while task.wait(0.25) do
local hum = plr.Character:WaitForChild("Humanoid")
local data = plr:WaitForChild("Data")
data.Required.Value = Tiers.TierReq[data.Tier.Value]
hum.WalkSpeed = 3 + (16 + math.pow(data.Tier.Value, 1.05)) + math.log(data.Power.Value, 40)
hum.JumpPower = 10 + (35 + math.pow(data.Tier.Value, 1.025)) + math.log(data.Power.Value, 125)
hum.MaxHealth = 100 + (math.pow(data.Tier.Value, 1.4)) * math.log(data.Power.Value, 2)
end
end)
function SpawnOrbs(pos, exp)
local exptodrop = exp/2
local expmin = math.round(exp/100)
local orbval = 0
local orbID = 0
local todrop = ""
while exptodrop > expmin do
for i, val in ipairs(OrbMod.Values) do
if val > orbval and exptodrop - val >= expmin then
orbval = val
orbID = i
end
end
exptodrop -= orbval
todrop = Tiers.TierList[orbID]
local clone = game.ServerStorage.OrbClone[todrop]:Clone()
clone.Parent = workspace.Orbs
clone.Position = pos
end
end
game.Players.PlayerAdded:Connect(function(plr) --start of the function that doesn't work
local bool = script.Died:Clone()
bool.Parent = plr
local data = plr:WaitForChild("Data")
task.wait(0.5)
plr.Character.Humanoid.Health = plr.Character.Humanoid.MaxHealth
plr.Character.Humanoid.Died:Connect(function()
plr:FindFirstChild("Died").Value = true
SpawnOrbs(plr.Character.Torso.Position, data.Power.Value)
data.Power.Value = 0
data.Tier.Value -= 1
task.wait(2)
plr.Character.Humanoid.Health = plr.Character.Humanoid.MaxHealth
plr:FindFirstChild("Died").Value = false
end)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.