Is this possibile?

So I came up with a idea and was wondering if it was actually possible to script before I possible start it?

  1. Could I make it so if someone touches a block everyone in the game dies and adds +1 to a leaderstat to Only The Player who touched it?
  2. Could I refer to all parts make it so that 1 randomly changes color?(Maybe in a folder)
  3. Could I make a script so that if any part is a certain color that it would have can collide off?

If you could give example scripts that would be nice too.

3 Likes

All those 3 are possible as they are simple enough to make

  1. The first can be made using the .Touched event of a part, you can do that, use a loop for all the players in game, check if their character exists and if it does, kill them

  2. Same thing, use .Touched, reference a folder with all the parts and get a random one via math.random

  3. You can do this one by combining it with the 2nd one or just use GetPropertyChangedSignal on the BrickColor and do something when a specific brickcolor is on the part, if you’re using brickcolor

If you require anymore assistance such as not understanding a certain thing, tell me I’ll help to the best of my ability

3 Likes

For the first one, you could have this

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
for i, v in pairs(game.Players:GetPlayers()) do
v.Character.Humanoid.Health = 0
end
end
end)

I want it to randomly change all the time

1: Yes it is, when the part is touched, loop through all the players and get their humanoid and set the health to 0
2: Yes you can as well, just use Random:NextInteger between 1 and all the amount of parts and choose a random part and change the color, if you want parts in all folders instead of just workspace, use GetDescendants
3: Yes you can, use GetDescendants and check if the child is a basepart and check if the part’s color is that specific color, if it is, turn CanCollide off

Ohh, then in case you can have a while true do loop and after a certain amount of time, get a random part from a folder and change its color

This kills all players in the game?

Wont this just mean closest player?

No, it just checks the parent and checks if there is a child called humanoid in it which would be a player

1 Like

But I want all the parts to be in there is there a way I can refer to them?

His code works like this

  • When something tocuhes the part, check if it’s a humanoid via the Parent of the hit part and finding the first thing called “Humanoid”
  • IF they are a humanoid, loop through all the players and set their character’s humanoid health to 0
1 Like

So wait, you want any part in the workspace to randomly change color? even if they aren’t in the folder?

1 Like

You can use a for i, v in pairs loop for that

1 Like

No just in the folder. All parts in that folder

Again it’s simple, use a while true do loop, after a certain amount of time, get a random part from the folder and set its color to random color. I think that’s what you wanted

1 Like

To do that, you have to get the children of that specific folder (if they are a BasePart) and than get a random part and change it’s color

1 Like

So again lets say if 10 people were in the game then 10 people would die with this code?

Yes, it loops through all of the players and finds their character

1 Like

That is correct, the only issue comes if one of those characters is nil, aka, not respawned by the time something tocuhes the part

1 Like

Somewhere in that code could it add to a leaderstat?

It’s possible yea, you just need a leaderstat script already done and just set whatever value you want to a leaderstat value in there