I was trying to edit SprintScript to make it enable effects for local player. It works in studio, but it doesnt work in game (Effects dont appear, it only changes WalkSpeed,FoV and JumpPower, puts sprint feature into infinite loop after i press shift while i am in game)
local mouse = game.Players.LocalPlayer:GetMouse() local running = false function getTool() for _, kid in ipairs(script.Parent:GetChildren()) do if kid.className == "Tool" then return kid end end return nil end mouse.KeyDown:connect(function (key) -- Run function key = string.lower(key) if string.byte(key) == 48 then running = true local keyConnection = mouse.KeyUp:connect(function (key) if string.byte(key) == 48 then running = false end end) for i = 1,5 do game.Workspace.CurrentCamera.FieldOfView = (160) wait() end game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 248 game.Players.LocalPlayer.Character.Humanoid.JumpPower = 250 game.Workspace.CurrentCamera.CC.Enabled = true game.Workspace.CurrentCamera.Blur.Enabled = true game.Players.LocalPlayer.PlayerGui.Sound:Play() game.Players.LocalPlayer.PlayerGui.Peace:Stop() game.Players.LocalPlayer.PlayerGui.Run.Enabled = true repeat wait () until running == false keyConnection:disconnect() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 12 game.Players.LocalPlayer.Character.Humanoid.JumpPower = 50 game.Workspace.CurrentCamera.CC.Enabled = false game.Workspace.CurrentCamera.Blur.Enabled = false game.Players.LocalPlayer.PlayerGui.Run.Enabled = false game.Players.LocalPlayer.PlayerGui.Sound:Stop() game.Players.LocalPlayer.PlayerGui.Peace:Play() for i = 1,5 do game.Workspace.CurrentCamera.FieldOfView = (70) wait() end end end)
How can I fix it?