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

how to fix this message with a status value that displays event if u have a flashlight?

Asked by
hokyboy 270 Moderation Voter
5 years ago
01game.Workspace.Door.Touched:Connect(function(hit)
02if hit.Parent:FindFirstChild("Flashlight") then
03game.Workspace.Door.CanCollide = false
04wait()
05else -- Else
06game.ReplicatedStorage.Status.Value = "Its to dark in this room maybe search for a flashlight"
07wait(2)
08game.ReplicatedStorage.Status.Value = ""
09end
10end)   

So i have this script if u touch a part and u have a flashlight u can go trough but it displays the message that u need to find one everytime how to fix this?

0
Please provide more information dr6g0nb0y 27 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Ok, lets try it

I already saw a lot of people missing the "equipped" function of the tools. So lets apply it here so you can know how to fix this problem again in the future!

First Step : We need to know how and where we can use the equipped() function. So lets take an expample I made.

01--> Locals <--
02 
03local tool = game:GetService("ReplicatedStorage").Tool
04local messageP = "We are fine!"
05 
06--> Code! <--
07 
08local function equipped()
09        print(messageP)
10end
11 
12script.Parent.Equipped:Connect(equipped)
13--> This will print the message when you equip the tool!

And that's how we get the "Equipped" function. We can get even a character or a Humanoid. But now we will use this even to make it like you want

Second Step : Enjoy coding! You always have to enjoy what are you doing! Play some music while you script or even play something before to be relaxed!

Lets get into the code!

01--> Functions <--
02 
03local function equipped()
04    if script.Parent.Equipped then
05        workspace:FindFirstChild("Door").CanCollide = false
06 
07        wait() --> Wait time you want
08    end
09end
10 
11local function equippedFinished()
12    if not script.Parent.Equipped then
13        game:GetService("ReplicatedStorage").Status.Value = "Its to dark here! You need a lintern! Or maybe a flashlight"
14        wait() --> Wait time you want
15        game:GetService("ReplicatedStorage").Status.Value = ""
View all 30 lines...

And that's all! Now you can enjoy your pieces of code! If this helps you let me know.

I hope my answer already solve your question. If is that the case, please accept my answer. That will help me a lot!

Keep scripting!

Ad

Answer this question