Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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!

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 Vulkarin 581 — 6y
0
I have already read that. User#21908 42 — 6y
0
I just don't know how I would do that. Do I need to use remote events/functions? User#21908 42 — 6y
0
Yes, you would need to use Remote Events. LegitmateTrades 159 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

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.

0
Ok I will try it out and if it works then I will accept your answer User#21908 42 — 6y
0
Sounds good. LegitmateTrades 159 — 6y
Ad

Answer this question