5% of Time/Points Dropped On Leave If Out Of Spawn

I have a sword fight and steal time game, and before I explain what I need help with I just want to say, I’ll use points instead of time so it’s more understandable.

So I had a script, I forgot what it was, but it was in serverscriptservice, and it was meant to drop 5% of the players points if they left the game without being in spawn.

Can anyone please write a possible small script and if not because it’s alot of lines to write then it’s alright!

1 Like

I mean, I do wan’t this so like… :frowning:

you’re not giving enough information in order for me to help you, so even if i wanted to make this script for you i couldn’t.

So I had a script, I forgot what it was, but it was in serverscriptservice, and it was meant to drop 5% of the players points if they left the game without being in spawn.

if you lost the script, you can revert to an older version of the game
if you can’t revert to an older version, then i can lead you to this page: ZonePlus v3.2.0 | Construct dynamic zones and effectively determine players and parts within their boundaries
you can connect a PlayerRemoving to the ZonePlus module and then remove the 5% of coins.

I never published, and I’m not a scripter, so it’s clearly going to not work.

maybe you can do a script where its the

bindtoclose event

where if the person isn’t touching the spawn’s hitbox then it gets the person’s points value and then
divides the player’s points value by 100 then times the points value after by 95 (which gets 5% of the points gone)

well then we can go right back to my first comment, do not directly ask people on the devforum to write scripts for you.
if you want a scripter to make a script for you, you can do one of the following:

  • contact a friend who knows how to script
  • commision someone to make the script for you
  • learn to script it yourself

BindToClose only fires once the server closes, not when a player leaves. only the last player would lose their 5%

the 5% must actually drop on the baseplate as any shape and if a player touches then they get it.

try this

local players = game.Players

local spawnhitbox =  -- put the name of the spawn's hitbox here
local istouching = Instance.new("BoolValue")
istouching.Value = false
	
	game.Players.PlayerAdded:Connect(function(player)
		clone = istouching:Clone()
		clone.Parent = player
		clone.Name = "IsTouchingSpawn"
	end)
	
	spawnhitbox.Touched:Connect(function(hit)
	player:WaitForChild("IsTouchingSpawn").Value = true
	end)
	
	spawnhitbox.TouchEnded:Connect(function()
	player:WaitForChild("IsTouchingSpawn").Value = false
	end)
	
players.PlayerRemoving:Connect(function(player)
	local character = player.Character
	if player:WaitForChild("IsTouchingSpawn").Value == false then
		
		player.leaderstats.Time.Value /= 100  -- Change time to the name of the value
		v = player.leaderstats.Time
		player.leaderstats.Time.Value *= 95  -- Change time to the name of the value
		
	   part = Instance.new("Part")
	   part.Size = Vector3.new(5, 3, 5)
	   part.CanCollide = true
	   part.Anchored = false
	   part.Parent = game.Workspace
	   part.Position = character.Torso.Position
	   part.Material = "Neon" -- you can also do Enum.Material.Neon
	   local partval = Instance.new("NumberValue")
	   partval.Value = v.Value
	   partval.Parent = part
	end
end)

part.Touched:Connect(function(hit)
	local char = hit.Parent
	local player = char:GetPlayerFromCharacter()
	player.leaderstats.Time.Value += v.Value -- change time to your value!!!
	part:Destroy()
end)

What script type and where to place it?

i havent tested it but

try making it as
a script in workspace
a script in serverscriptservice
a localscript in workspace

to see if it works

do each one at a time and tell me if there are errors

Thanks, also do you mean localscript in startergui or workspace?

just workspace

post character limit bypass HAHAHHAHAHHAA

Okay, none of them worked? Now what :frowning:

how did you check it, also if there were any errors in the console tell me them

and also show me the script u added completely, cause there were some things u might of needed to change so show me the script u showed

I used my friend to test in real roblox game

were there any console errors at all?

let me re-test and let ya know

if it still doesnt work maybe change playerremoved to childremoved