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

How would you fix the mouse maniplulation lock?

Asked by 3 years ago
Edited 3 years ago

I was working on a script to make my gun lock then the tool is equipped. i works but then when I unequipped i it stays I've tried to set the setting to false that didn't work here's the script:

local player = game.Players.LocalPlayer local uis = game:GetService("UserInputService") local mouse = print("Holding gun")

repeat wait(1) until player.Character

local character = player.Character

local humanoid = character:WaitForChild("Humanoid")

local animation = Instance.new("Animation")

animation.Name = "Idle"

animation.Parent = script.Parent

animation.AnimationId = "http://www.roblox.com/asset/?id=6688751964"

local animtrack = humanoid:LoadAnimation(animation)

script.Parent.Equipped:connect(function() mouse = true if mouse == true then uis.MouseBehavior = Enum.MouseBehavior.LockCenter end animtrack:Play()

end)

script.Parent.Unequipped:connect(function() mouse = false if mouse == false then uis.MouseBehavior = Enum.MouseBehavior.LockCenter == false end animtrack:Stop()

end)

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Click "View Source" in the top right, then copy the code and paste it in your script

local player = game.Players.LocalPlayer 
local uis = game:GetService("UserInputService") 
local mouse = player:GetMouse()

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")

animation.Name = "Idle"
animation.AnimationId = "http://www.roblox.com/asset/?id=6688751964"
animation.Parent = script.Parent

local animtrack = humanoid:LoadAnimation(animation)
local equipped = false

script.Parent.Equipped:connect(function() 
    equipped = true 
    uis.MouseBehavior = Enum.MouseBehavior.LockCenter
    animtrack:Play()
end)

script.Parent.Unequipped:connect(function() 
    equipped = false 
    uis.MouseBehavior = Enum.MouseBehavior.Default
    animtrack:Stop()
end)
0
Click "Accept Answer" beside my answer if this helped Shounak123 461 — 3y
0
It did thank you KEVINRUANO 12 — 3y
0
I did but when I refresh it doesn't accept the answer KEVINRUANO 12 — 3y
0
ok now it did Shounak123 461 — 3y
0
Anyways I'm glad this helped Shounak123 461 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

You're defining the variable "mouse" as a function, "print("Holding gun")". Then later, you attempt to change that variable to true and false. Did you mean

local mouse = false

Also, can you put the specific error?

Answer this question