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

i tried to make a flashlight, but it work when key is down, how to make key press?

Asked by 4 years ago

script:

01local light = Instance.new('SurfaceLight')
02local humanoidrootpart = script.Parent:WaitForChild("HumanoidRootPart")
03 
04 
05repeat wait() until game.Players.LocalPlayer
06 
07 
08local humanoidrootpart = game.Players.LocalPlayer.character:WaitForChild("HumanoidRootPart")
09local mouse = game.Players.LocalPlayer:GetMouse()
10light.Parent = humanoidrootpart
11light.Brightness = 0
12 
13 
14mouse.KeyDown:connect(function(key)
15    if key == "f" then
View all 39 lines...

0
and yes, it is in startercharacter scripts, and inside of a local script TinkyWinkyDev 6 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Put the below in a localscript

01local Mouse = game.Players.LocalPlayer:GetMouse()
02local on = false
03local pointLight = script.Parent.FlashLightHead.PointLight
04--set pointLight to the location of the PointLight that controls the flashlight's light
05Mouse.Button1Down:Connect(function()
06if on then
07on = false
08pointLight.Range = 0
09else
10on = true
11pointLight.Range = 8
12end
13end
0
thx TinkyWinkyDev 6 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Try MouseClick

0
np, mouseclick is not a valid member of mouse TinkyWinkyDev 6 — 4y

Answer this question