Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I trick the player into thinking there is no lag with boxes I have?

I have a script which randomly drops boxes around the map. The code is thus:

	local function randomBoxSpawner()
		
		local boxName = randomBoxChooser()
		local boxCopy = serverStorage.Boxes:FindFirstChild(boxName):Clone()
		local prize = boxCopy:WaitForChild("Prize").Value
		local debounce = true
		
		if boxCopy and prize then
			
			boxCopy.Parent = game.Workspace
			boxCopy.CFrame = randomLocationProvider()
			debris:AddItem(boxCopy, debrisWaitTime)
			
			boxCopy.Touched:Connect(function(hit)
				
				local humanoid = hit.Parent:FindFirstChild("Humanoid")
				
				if humanoid and humanoid.Health > 0 then
					if debounce then
						
						local player = players:GetPlayerFromCharacter(hit.Parent)
						local playerInfo = serverStorage:FindFirstChild(player.Name).PlayerInfo
						
						if playerInfo.OwnsTycoon.Value then
							
							debounce = false
							
							awardBoxPrize(boxCopy, playerInfo, prize)
							
						end
						
					end
				end
				
			end)
			
		end
	end

The problem is that when I touch the box in a server it takes about one to two seconds to disappear. I thought about fading it out with a for loop but still would it not lag? What is a way that I can fix this? Quick note: I am not asking for a script, just a way to understand and fix this "problem". Thanks!

4 comments

0

Your best bet is to have the client do a little bit of fading on their own while the server processes what happens, there's a wiki tutorial that's kinda related here http://robloxdev.com/articles/Fighting-Against-Lag

0

I have already read that.

0

I just don't know how I would do that. Do I need to use remote events/functions?

0

Yes, you would need to use Remote Events.

1 answer

My suggestion would be as you say to fade out the box however I would suggest doing this client side so it fades out on the client side however dissapears server side. As they do not know when you touch it to open it they will not really notice the delay.

2 comments

0

Ok I will try it out and if it works then I will accept your answer

0

Sounds good.

This discussion is preserved as it was. New answers, comments, and votes are closed.