Hi, I made this this orb where it drops on death, but recently I remembered that players can reset over and over and re claim the orb for levels, how can I prevent this for normal players and players who have a gamepass(for 2x levels). In case you don’t understand, I’m trying to stop players from collecting their own dropped orb so yeah.
PLZ HELP
Here is the script:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if hit.Parent.Humanoid.Health > 0 then
player.leaderstats.Levels.Value = player.leaderstats.Levels.Value + 1
script.Parent:Destroy()
end
end
end)
You would need to store some sort of reference (name, userid, etc.) to the player who dropped the orb. You can do this with a ValueObject or an Attribute or anything you want.
You can create a Boolean value inside of the player that determines if the player has picked it up yet, shown here:
-- You would run this in a player added function
local BoolValue = Instance.new("BoolValue")
BoolValue.Parent = Player
BoolValue.Name = "BoolValue"
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local getValue = player:WaitForChild("BoolValue")
if getValue.Value ~= true then
getValue.Value = true
-- CODE
wait(10) -- Wait 10 Seconds Before The Player Can Pick Up Again
getValue.Value = false
end