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

Why isn't this LocalScript shaking the script when the player left clicks?

so this is a LocalScript inside of StarterCharacterScripts, but since I'm paranoid I also put it into StarterPlayerScripts. It's meant to shake the screen and change the camera's angle when the player left clicks.

local character = script.Parent
local plr = game.Players[character.Name]
local mouse = plr:GetMouse()

function Shake()
	
	for i = 0, 1, 0.2 do
	workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(.02,math.rad(.1),0.02)
	game:GetService("RunService").RenderStepped:Wait()
	end
	for i = 0 ,1, 0.2 do
	workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(-.01,math.rad(-.1),-0.01)
	game:GetService("RunService").RenderStepped:Wait()
	end
		
		mouse.Button1Down:Connect(function()
			Shake()
		end)
	end


What did I do wrong?

3 comments

0

any errors?

0

No, nothing actually.

0

Well, you're calling the function inside of the function itself. Take the mouse.Button1Down part out of it and put it below it.

1 answer

✓ Accepted answer
local character = script.Parent
local plr = game.Players[character.Name]
local mouse = plr:GetMouse()

function Shake()
   	 for i = 0, 1, 0.2 do
		workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(.02,math.rad(.1),0.02)
		game:GetService("RunService").RenderStepped:Wait()
   	 end
   	 for i = 0 ,1, 0.2 do
    		workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(-.01,math.rad(-.1),-0.01)
		game:GetService("RunService").RenderStepped:Wait()
	end
end

mouse.Button1Down:Connect(function()
	Shake()
end)

1 comment

0

I found made another solution, but this also worked so thanks

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