I have a issue with my game.
Its laggy.
Im not sure whats causing the lagg… is there any way we can find out what makes it laggy?
Is it possible to see if it is a script that makes it laggy?
I really have no idea how to understand scripts. I can read a little of it, but I cant make my own.
Is it possible that my game is just too big and thats causing the lagg?
My games name is: CrazyTown- Thief and Poilce (tag edition)
This is in my output… i have no idea how to find all sounds
15:22:30.109 Infinite yield possible on ‘Workspace.RedHyperGun.Handle:WaitForChild(“HitFade”)’ - Studio
15:22:30.110 Stack Begin - Studio
15:22:30.110 Script ‘Workspace.Blue Lazer Gun.HyperlaserGun.Script’, Line 17 - Studio - Script:17
15:22:30.110 Stack End - Studio
15:22:30.481 Failed to load animation with sanitized ID rbxassetid://867461219: Animation failed to load, assetId: https://assetdelivery.roblox.com/v1/asset?id=867461219&serverplaceid=0 - Studio
15:22:31.593 [ACTION ITEM] Experience doesn’t have permissions for sound asset 184542505. Click here to grant experience permission to asset. - Studio
15:22:31.593 Failed to load sound http://www.roblox.com/asset/?id=184542505: User is not authorized to access Asset. - Studio
15:22:31.594 [ACTION ITEM] Experience doesn’t have permissions for sound asset 184542511. Click here to grant experience permission to asset. - Studio
15:22:31.594 Failed to load sound http://www.roblox.com/asset/?id=184542511: User is not authorized to access Asset. - Studio
15:22:31.739 Moved To Position!:44 - Server - Script:5
15:22:31.787 Failed to load animation with sanitized ID rbxassetid://867501572: Animation failed to load, assetId: https://assetdelivery.roblox.com/v1/asset?id=867501572&serverplaceid=0 - Studio
15:22:32.067 Failed to load sound rbxassetid://1: Request asset was not found (x2) - Studio
15:22:32.127 Failed to load animation with sanitized ID rbxassetid://867501572: Animation failed to load, assetId: https://assetdelivery.roblox.com/v1/asset?id=867501572&serverplaceid=0 - Studio
15:22:33.951 [ACTION ITEM] Experience doesn’t have permissions for sound asset 306360025. Click here to grant experience permission to asset. - Studio
15:22:33.952 Failed to load sound http://www.roblox.com/asset/?id=306360025: User is not authorized to access Asset. - Studio
15:22:33.952 [ACTION ITEM] Experience doesn’t have permissions for sound asset 168012228. Click here to grant experience permission to asset. - Studio
15:22:33.952 Failed to load sound http://www.roblox.com/asset/?id=168012228: User is not authorized to access Asset. - Studio
15:22:33.952 [ACTION ITEM] Experience doesn’t have permissions for sound asset 1274626097. Click here to grant experience permission to asset. - Studio
15:22:33.952 Failed to load sound rbxassetid://1274626097: User is not authorized to access Asset. - Studio
15:22:33.952 [ACTION ITEM] Experience doesn’t have permissions for sound asset 1280470. Click here to grant experience permission to asset. - Studio
15:22:33.952 Failed to load sound http://www.roblox.com/asset/?id=1280470: User is not authorized to access Asset. - Studio
15:22:34.305 Failed to load sound rbxasset://sounds/swoosh.wav: Asset is not approved for the requester - Studio
15:22:35.457 Failed to load sound rbxasset://sounds/swoosh.wav: Temp read failed. (x4) - Studio
15:22:36.491 [ACTION ITEM] Experience doesn’t have permissions for sound asset 2652214165. Click here to grant experience permission to asset. - Studio
15:22:36.491 Failed to load sound rbxassetid://2652214165: User is not authorized to access Asset. - Studio
15:22:36.859 Failed to load sound http://www.roblox.com/asset/?id=: HTTP 404 (Not Found) (x2) - Studio
15:22:37.047 Failed to load sound rbxasset://sounds/swoosh.wav: Temp read failed. - Studio
15:22:37.297 Failed to load sound http://www.roblox.com/asset/?id=: Temp read failed. (x2) - Studio
15:22:37.572 Moved To Position!:5 - Server - Script:5
15:22:43.828 DataPersistence is deprecated, please use DataStoreService instead. (x3) - Studio
15:22:43.690 Disconnect from ::ffff:127.0.0.1|63392 - Studio
15:22:44.025 DataStoreService: StudioAccessToApisNotAllowed: Cannot write to DataStore from studio if API access is not enabled. API: SetAsync, Data Store: SaveLeaderstats - Studio
15:22:44.026 ServerScriptService.leaderstats.Script:34: 403: Cannot write to DataStore from studio if API access is not enabled. - Server
15:22:44.026 Stack Begin - Studio
15:22:44.026 Script ‘ServerScriptService.leaderstats.Script’, Line 34 - function Save - Studio
15:22:44.026 Stack End - Studio
15:22:44.094 Workspace.x2WalkSpeed:4: attempt to index nil with ‘FindFirstChild’ - Server
15:22:44.094 Stack Begin - Studio
15:22:44.094 Script ‘Workspace.x2WalkSpeed’, Line 4 - Studio
15:22:44.094 Stack End - Studio
15:22:44.353 Moved To Position!:19 - Server
The developer console allows you to inspect the script activity, memory usage, and more.
I just hopped in and didn’t experience any significant frame loss, so I assume you’re talking about server-side lag, which in this case is very likely to be caused by a script, or possibly even multiple.
I can’t do this myself, but as you’re the developer, you should be able to access server-side logs in-game. If you press F9, you’ll open the Developer Console.
Proceed to the Scripts tab, which will show something like this. If any of the scripts are causing lag, you should be able to see a high activity/rate beside them.
i found it how high is too high?
i found one the is weird… it says zombie script… i dont even have zombies in the game anymore… how do i find the right script?
It seems more like the ToolPickupHandler is the issue.
In the Studio Explorer, just type ToolPickupHandler into the search bar, and send whatever code is inside.
local pps = game:GetService("ProximityPromptService")
local distance = 10
local timeToHold = 0.5
pps.PromptTriggered:Connect(function(pp, plr)
local tool = pp.Parent.Parent
if tool:IsA("Tool") then
tool.Parent = plr.Backpack
pp:Destroy()
end
end)
while wait() do
for i, descendant in pairs(workspace:GetDescendants()) do
if descendant:IsA("Tool") and descendant:FindFirstChild("Handle") and not game.Players:GetPlayerFromCharacter(descendant.Parent) then
if descendant.Handle:FindFirstChild("TouchInterest") then descendant.Handle.TouchInterest:Destroy() end
local pp = descendant.Handle:FindFirstChild("ProximityPrompt")
if not pp then
pp = Instance.new("ProximityPrompt")
pp.MaxActivationDistance = distance
pp.HoldDuration = timeToHold
pp.ObjectText = "Tool"
pp.ActionText = "Pick Up"
pp.Parent = descendant.Handle
end
end
end
end
idk what it does… its under nothing… just under workspace
That’s a very big performance tank, lol.
Every server tick, it gets and loops through every descendant of the workspace, which is very expensive.
For now, I’d just change the while wait() do
to while task.wait(5) do
.
It seems to handle creating proximity prompts for tools so you can pick them up with the prompt, but that was a dumb way to write it.
Make sure your game uses StreamingEnabled, was a huge saver for me.
i found the zombie script too… its in a DOG hahahaha
--Made by Stickmasterluke
--Zombie artificial stupidity script
sp=script.Parent
lastattack=0
nextrandom=0
nextsound=0
nextjump=0
chasing=false
variance=4
damage=50
attackrange=4.5
sightrange=999--60
runspeed=40
wonderspeed=8
healthregen=false
colors={"Sand red","Dusty Rose","Medium blue","Sand blue","Lavender","Earth green","Brown","Medium stone grey","Brick yellow"}
function raycast(spos,vec,currentdist)
local hit2,pos2=game.Workspace:FindPartOnRay(Ray.new(spos+(vec*.01),vec*currentdist),script.Parent)
if hit2~=nil and pos2 then
if hit2.Parent==script.Parent and hit2.Transparency>=.8 or hit2.Name=="Handle" or string.sub(hit2.Name,1,6)=="Effect" or hit2.Parent:IsA("Hat") or hit2.Parent:IsA("Tool") or (hit2.Parent:FindFirstChild("Humanoid") and hit2.Parent:FindFirstChild("TEAM") and hit2.Parent:FindFirstChild("TEAM").Value == script.Parent.TEAM.Value) or (not hit2.Parent:FindFirstChild("Humanoid") and hit2.CanCollide==false) then
local currentdist=currentdist-(pos2-spos).magnitude
return raycast(pos2,vec,currentdist)
end
end
return hit2,pos2
end
function waitForChild(parent,childName)
local child=parent:findFirstChild(childName)
if child then return child end
while true do
child=parent.ChildAdded:wait()
if child.Name==childName then return child end
end
end
-- ANIMATION
-- declarations
local Torso=waitForChild(sp,"Torso")
local Head=waitForChild(sp,"Head")
local RightShoulder=waitForChild(Torso,"Right Shoulder")
local LeftShoulder=waitForChild(Torso,"Left Shoulder")
local RightHip=waitForChild(Torso,"Right Hip")
local LeftHip=waitForChild(Torso,"Left Hip")
local Neck=waitForChild(Torso,"Tail")
local Humanoid=waitForChild(sp,"Humanoid")
local BodyColors=waitForChild(sp,"Body Colors")
local pose="Standing"
local hitsound=waitForChild(Head,"Bite Bark")
local BARKING=waitForChild(Head,"Seal Barking")
--[[local sounds={
waitForChild(Torso,"GroanSound"),
waitForChild(Torso,"RawrSound")
}]]
if healthregen then
local regenscript=waitForChild(sp,"HealthRegenerationScript")
regenscript.Disabled=false
end
Humanoid.WalkSpeed=wonderspeed
local toolAnim="None"
local toolAnimTime=0
--[[BodyColors.HeadColor=BrickColor.new("Grime")
local randomcolor1=colors[math.random(1,#colors)]
BodyColors.TorsoColor=BrickColor.new(randomcolor1)
BodyColors.LeftArmColor=BrickColor.new(randomcolor1)
BodyColors.RightArmColor=BrickColor.new(randomcolor1)
local randomcolor2=colors[math.random(1,#colors)]
BodyColors.LeftLegColor=BrickColor.new(randomcolor2)
BodyColors.RightLegColor=BrickColor.new(randomcolor2)]]
function onRunning(speed)
if speed>0 then
pose="Running"
else
pose="Standing"
end
end
function onDied()
pose="Dead"
end
function onJumping()
pose="Jumping"
end
function onClimbing()
pose="Climbing"
end
function onGettingUp()
pose = "GettingUp"
end
function onFreeFall()
pose = "FreeFall"
end
function onFallingDown()
pose = "FallingDown"
end
function onSeated()
pose = "Seated"
end
function onPlatformStanding()
pose = "PlatformStanding"
end
function moveJump()
RightShoulder.MaxVelocity = 0.5
LeftShoulder.MaxVelocity = 0.5
RightShoulder.DesiredAngle=3.14
LeftShoulder.DesiredAngle=-3.14
RightHip.DesiredAngle=0
LeftHip.DesiredAngle=0
end
function moveFreeFall()
RightShoulder.MaxVelocity = 0.5
LeftShoulder.MaxVelocity =0.5
RightShoulder.DesiredAngle=3.14
LeftShoulder.DesiredAngle=-3.14
RightHip.DesiredAngle=0
LeftHip.DesiredAngle=0
end
function moveSit()
RightShoulder.MaxVelocity = 0.15
LeftShoulder.MaxVelocity = 0.15
RightShoulder.DesiredAngle=3.14 /2
LeftShoulder.DesiredAngle=-3.14 /2
RightHip.DesiredAngle=3.14 /2
LeftHip.DesiredAngle=-3.14 /2
end
function animate(time)
local amplitude
local frequency
if (pose == "Jumping") then
moveJump()
return
end
if (pose == "FreeFall") then
moveFreeFall()
return
end
if (pose == "Seated") then
moveSit()
return
end
local climbFudge = 0
if (pose == "Running") then
RightShoulder.MaxVelocity = 0.15
LeftShoulder.MaxVelocity = 0.15
amplitude = 1
frequency = 9
elseif (pose == "Climbing") then
RightShoulder.MaxVelocity = 0.5
LeftShoulder.MaxVelocity = 0.5
amplitude = 1
frequency = 9
climbFudge = 3.14
else
amplitude = 0.1
frequency = 1
end
desiredAngle = amplitude * math.sin(time*frequency)
if not chasing and frequency==9 then
frequency=4
end
if chasing then
--[[RightShoulder.DesiredAngle=math.pi/2
LeftShoulder.DesiredAngle=-math.pi/2
RightHip.DesiredAngle=-desiredAngle*2
LeftHip.DesiredAngle=-desiredAngle*2]]
else
RightShoulder.DesiredAngle=desiredAngle + climbFudge
LeftShoulder.DesiredAngle=desiredAngle - climbFudge
RightHip.DesiredAngle=-desiredAngle
LeftHip.DesiredAngle=-desiredAngle
end
end
function attack(time,attackpos)
if time-lastattack>=0.25 then
local hit,pos=raycast(Torso.Position,(attackpos-Torso.Position).unit,attackrange)
if hit and hit.Parent~=nil then
local h=hit.Parent:FindFirstChild("Humanoid")
local TEAM=hit.Parent:FindFirstChild("TEAM")
if h and TEAM and TEAM.Value~=sp.TEAM.Value then
local creator=sp:FindFirstChild("creator")
if creator then
if creator.Value~=nil then
if creator.Value~=game.Players:GetPlayerFromCharacter(h.Parent) then
for i,oldtag in ipairs(h:GetChildren()) do
if oldtag.Name=="creator" then
oldtag:remove()
end
end
creator:clone().Parent=h
else
return
end
end
end
hitsound.Volume=1
hitsound.Pitch=.75+(math.random()*.5)
hitsound:Play()
wait(0.15)
h:TakeDamage(damage)
--[[if RightShoulder and LeftShoulder then
RightShoulder.CurrentAngle=0
LeftShoulder.CurrentAngle=0
end]]
end
end
lastattack=time
end
end
Humanoid.Died:connect(onDied)
Humanoid.Running:connect(onRunning)
Humanoid.Jumping:connect(onJumping)
Humanoid.Climbing:connect(onClimbing)
Humanoid.GettingUp:connect(onGettingUp)
Humanoid.FreeFalling:connect(onFreeFall)
Humanoid.FallingDown:connect(onFallingDown)
Humanoid.Seated:connect(onSeated)
Humanoid.PlatformStanding:connect(onPlatformStanding)
function populatehumanoids(mdl)
if mdl.ClassName=="Humanoid" then
if mdl.Parent:FindFirstChild("TEAM") and mdl.Parent:FindFirstChild("TEAM").Value~=sp.TEAM.Value then
table.insert(humanoids,mdl)
end
end
for i2,mdl2 in ipairs(mdl:GetChildren()) do
populatehumanoids(mdl2)
end
end
--[[function playsound(time)
nextsound=time+5+(math.random()*5)
local randomsound=sounds[math.random(1,#sounds)]
randomsound.Volume=.5+(.5*math.random())
randomsound.Pitch=.5+(.5*math.random())
randomsound:Play()
end]]
while sp.Parent~=nil and Humanoid and Humanoid.Parent~=nil and Humanoid.Health>0 and Torso and Head and Torso~=nil and Torso.Parent~=nil do
local _,time=wait(0.25)--wait(1/3)
humanoids={}
populatehumanoids(game.Workspace)
closesttarget=nil
closestdist=sightrange
local creator=sp:FindFirstChild("creator")
for i,h in ipairs(humanoids) do
if h and h.Parent~=nil then
if h.Health>0 and h.Parent~=sp then
local plr=game.Players:GetPlayerFromCharacter(h.Parent)
if creator==nil or plr==nil or creator.Value~=plr then
local t=h.Parent:FindFirstChild("Torso")
if t~=nil then
local dist=(t.Position-Torso.Position).magnitude
if dist<closestdist then
closestdist=dist
closesttarget=t
end
end
end
end
end
end
if closesttarget~=nil then
if not chasing then
--playsound(time)
chasing=true
Humanoid.WalkSpeed=runspeed
BARKING:Play()
end
Humanoid:MoveTo(closesttarget.Position+(Vector3.new(1,1,1)*(variance*((math.random()*2)-1))),closesttarget)
if math.random()<.5 then
attack(time,closesttarget.Position)
end
else
if chasing then
chasing=false
Humanoid.WalkSpeed=wonderspeed
BARKING:Stop()
end
if time>nextrandom then
nextrandom=time+3+(math.random()*5)
local randompos=Torso.Position+((Vector3.new(1,1,1)*math.random()-Vector3.new(.5,.5,.5))*40)
Humanoid:MoveTo(randompos,game.Workspace.Terrain)
end
end
if time>nextsound then
--playsound(time)
end
if time>nextjump then
nextjump=time+7+(math.random()*5)
Humanoid.Jump=true
end
animate(time)
end
wait(4)
sp:remove() --Rest In Pizza
idk what that is… can u explain pls?
ohh… u made it go back to 0 from time to time… thank you <3
should i just delete the dog? it just walks and barks
I mean… I don’t exactly know what your game is going for, so I can’t say for myself.
It feels like a hangout game that I’d make back in the day, so you could try replacing it with something else.
its a hangout place if u choose adventurer… if u choose police or thief its a tag game… but i cant fix all script hahahahaha… I will delete the dog it doesnt affect the game
i will tell my kids to test the game if its still laggy
StreamingEnabled is a feature you can enable under the Workspace, which essentially unloads things (on the client) that are outside of a certain range. But it’s generally used for improved client performance, since the server still has to load everything in (unless no clients have it loaded I think).
haha i have been looking for that! so it loads just a little at a time… since the map is kinda big… I will read about it now that i know the name of it