Hello,
So I got a TextLabel letter “o” in the center of the screen serving as a cursor for my horror game. I tried replacing the actual game cursor a bit ago with a decal but couldn’t find the exact one I was looking for which once again is why I went with a TextLabel instead. Alright anyways, I got a LocalScript in StarterGui which removes the mouse icon. Looks like this:
local userInputService = game:GetService("UserInputService")
userInputService.MouseIconEnabled = false
Simple stuff, no problem until you come across this one puzzle in my game where a GUI pops up and you manually need to put in the code in clicking the button numbers.
My game is in LockFirstPerson and when the GUI pops up, I have it so the mouse unlocks. The thing is, due to the script from earlier, you almost have to guess where the mouse is at while moving it around. This is not efficient at all and is simply annoying. Now here is the code for the door.
--Waiting for objects to load
local Configuration = script.Parent:WaitForChild("Configuration")
local Code = Configuration:WaitForChild("Code")
local TimeOpen = Configuration:WaitForChild("TimeOpen")
local SlidingTime = Configuration:WaitForChild("SlidingTime")
local Height = Configuration:WaitForChild("Height")
local Button = script.Parent:WaitForChild("Button"):WaitForChild("ProximityPrompt")
local Light = script.Parent:WaitForChild("Light")
local Door = script.Parent:WaitForChild("Door")
--Tweening
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(SlidingTime.Value,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
--Other variables
local open = false
local opensound = script.Parent.Door.cellopen
Button.Triggered:Connect(function(player)
local newcode = game.ReplicatedStorage:WaitForChild("CodeDoor"):InvokeClient(player) --we invoke the players client and wait until they return the code
if newcode == Code.Value and open == false then
print('correct')
open = true
local goal1 = {CFrame = Door.CFrame + Vector3.new(0,Height.Value,0)} --CFrame of the door when it moves up, used for tween1
local goal2 = {CFrame = Door.CFrame} --Devault CFrame for the door, used for tween2
local tween1 = tweenService:Create(Door,tweenInfo,goal1) --opening tween
local tween2 = tweenService:Create(Door,tweenInfo,goal2) --closing tween
Light.Color = Color3.fromRGB(73, 181, 71) --Light (part) color changes
Light.PointLight.Color = Color3.fromRGB(73, 181, 71)--PointLight color changes (optional, disabled by default)
tween1:Play() --The door opens because we play the opening tween
opensound:Play()
script.Parent.Button.ProximityPrompt.Enabled = false
script:Destroy()
else --If the code is wrong, print "incorrect"
print('incorrect')
end
end)
I want to know if there’s a way to show the mouse again when the GUI is up and disappear again once closed with how things are set up right now. I’ve tried putting
userInputService.MouseIconEnabled = true
Below the
if newcode == Code.Value and open == false then
line from the top of the door’s script, when then I then put
userInputService.MouseIconEnabled = false
Right below
script.Parent.Button.ProximityPrompt.Enabled = false
at the bottom of the door’s script in hopes that it would somehow work. Unfortunately it didn’t and since I don’t really specialize in scripting I wouldn’t know what to do. I really hope this makes sense and I’d truly appreciate any help!