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

How do I make it so that a certain part of a script only starts when touching a certain part?

Asked by 4 years ago

I'm making a game with a script THAT CHANGES THE PLAYERS SCORE EVERY SECOND, AND RESETS BACK TO ZERO WHEN THE PLAYER DIES. This works fine. However, I need the timer to only start when the player isn't touching a certain part (Called "StartPart"). I still need to keep the same aspects of the script I meantioned above (In CAPITALS). Sorry if the script is a bit confusing. Here's the script I have currently:

01local Players = game:GetService("Players")
02    local UpdatePoints = false
03 
04    Players.PlayerAdded:Connect(function(Player)  
05            Player.CharacterAdded:Connect(function(Character)
06                    UpdatePoints = true
07 
08                    local Leaderstats = Instance.new("Folder")
09                    Leaderstats.Name = "leaderstats"
10                    Leaderstats.Parent = Player
11 
12                    local Points = Instance.new("IntValue")
13                    Points.Name = "Points"
14                    Points.Parent = Leaderstats
15 
View all 32 lines...

1 answer

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

Use a if then event to detect if the player is touching the part, if they are, break the script

I dont really know how to execute this but ill try

1local function onTouch(part)
2    return end
3end
4part.Touched:Connect(onTouch)

it probably doesnt work so here are the dev forum links

https://devforum.roblox.com/t/can-someone-explain-returning-to-me-like-im-3/206702/2 returning ^

https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched

Touched event ^

0
could you actually write the script? pugguy1000 3 — 4y
0
ill try to do research on the dev forum i know the actually idea just needa know how to execute it, just wait Radiant_Sparkles 69 — 4y
0
k... pugguy1000 3 — 4y
Ad

Answer this question