Speed Orbs For Simulator

Im Trying to have a basic orb around the starting area that gives you lets say +25 speed, I have the basic script down to do that but the orb disappears for every user & this is a 10 person lobby, how can I make the orb be individual to where when one person grabs it it disappears & remains on the timer for them but if another user hasnt claimed the orb, it will still be there to grab if that makes sense

waittime = 30 -- Sec Between each claim
amnt = 10 --how many speed points you get for it
function onTouched(part)
	local h = part.Parent:findFirstChild("Humanoid")
	if (h~=nil) then
		local thisplr = game.Players:findFirstChild(h.Parent.Name)
		if (thisplr~=nil) then
			local stats = thisplr:findFirstChild("leaderstats")
			if (stats~=nil) then
				local score = stats:findFirstChild("Speed")
				if (score~=nil) then
					score.Value = score.Value + amnt
				end
			end
		end
		
		script.Parent.Transparency = 1
		script.Disabled = true
		wait(waittime)
		script.Parent.Transparency = 0.5
		script.Disabled = false		


	end
end

script.Parent.Touched:connect(onTouched)
1 Like

Make the orb dissapear locally, and make the countdown checking on the server.

1 Like

Sorry im kind of a novice scriptor, can you walk me through that?

1 Like

Based upon the suggested solution, to make something dissappear locally, you could set the transparency / delete the orb on the client. Due to Filtering Enabled, this will not replicate to other clients. You could track each orb on the server by holding each one in a dictionary with any relevant information.

local Orbs = {
    [workspace.Orbs.OrbA] = {
        SpawnTime = 1699372128
    }
}

The code above is just an example. The SpawnTime is a unix timestamp.

Wha- this is so confusing ong.

first have a bool value of some sort in the player for “orbGone” and set it to false
add a remote event to replicated storage and rename it to something like “orbEvent”
add a unix time for when the orb should despawn for a specific player (you can make a dictionary and add the player to the table with a despawn time)
add a coroutine to check for each player when the orb should despawn
if the current unix time is greater than the orb despawn time, fire the orbEvent with a variable “Timeout”
if the player touched the orb fire the orbEvent with a variable “Claimed” and give the player the points
on a local script, listen for the event and check for the variable
if the variable is “Timeout”, remove the object from the workspace through the local script
maybe send a message saying “Orb timed out”
if the variable is “Claimed” remove the object from the workspace to the local script
maybe send a message saying “Orb claimed! +25 points”
this is a fairly basic script system. you should be able to understand it

1 Like