|
| 01 Jun 2015 11:23 PM |
local Debounce = false script.Parent.Touched:connect(function(Player) if not Debounce then Debounce = true for _, Player in pairs(game.Players:GetPlayers()) do local Character = Player.Character if Character then local Value = Instance.new("StringValue", script.Parent) Value.Value = Player.Name if not Value.Value == Player.Name then local Humanoid = Player.Character:FindFirstChild("Humanoid") if Humanoid and Humanoid.Health > 0 then Humanoid.Health = 0 end end end end end end)
1. The first player that sits, gets a value put into the seat. 2. If another player touches it, and they're name isn't that the value says, then it kills them.
I stole YOUR siggy. |
|
|
| Report Abuse |
|
|
| |
|
Rukiryo
|
  |
| Joined: 04 Sep 2009 |
| Total Posts: 1490 |
|
|
| 02 Jun 2015 12:26 AM |
Touched returns the part that touched the seat, not the player.
script.Parent.Touched:connect(function(hit)
Where hit is the part that's touched the brick. You then need to check if it's a player.
|
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 12:28 AM |
so
if hit.Parent:FindFirstChild("Humanoid") then
I stole YOUR siggy. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 12:30 AM |
So, is this all I had to do?
local Debounce = false script.Parent.Touched:connect(function(hit) if hit.Parent:FindFindFirstChild("Humanoid") then if not Debounce then Debounce = true for _, Player in pairs(game.Players:GetPlayers()) do local Character = Player.Character if Character then local Value = Instance.new("StringValue", script.Parent) Value.Value = Player.Name if not Value.Value == Player.Name then local Humanoid = Player.Character:FindFirstChild("Humanoid") if Humanoid and Humanoid.Health > 0 then Humanoid.Health = 0 end end end end end end end)
I stole YOUR siggy. |
|
|
| Report Abuse |
|
|
Rukiryo
|
  |
| Joined: 04 Sep 2009 |
| Total Posts: 1490 |
|
|
| 02 Jun 2015 12:30 AM |
Yes.
script.Parent.Touched:connect(function(hit) if hit.Parent:findFirstChild("Humanoid") ~= nil then local player = game.Players:findFirstChild(hit.Parent.Name) end end)
The 'player' variable will be the player that touched it.
Warning: If you have NPCs with humanoids, this could break it. You would want to check if player is nil if you're going to use humanoids that aren't players. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 12:31 AM |
Ugh Confusing, what about the rest of the script?
I stole YOUR siggy. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 12:33 AM |
I never have worked with function(hit) in my life, so I might need a ltitle extra on it. And also, it makes no sense because the previous script worked just find, just needed a little bit efficient checking.
I stole YOUR siggy. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 12:33 AM |
Excuse my grammar errors, didn't notice them.
I stole YOUR siggy. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 12:34 AM |
*A little bit more efficient checking
I stole YOUR siggy. |
|
|
| Report Abuse |
|
|
Rukiryo
|
  |
| Joined: 04 Sep 2009 |
| Total Posts: 1490 |
|
|
| 02 Jun 2015 12:35 AM |
Just roughly wrote this, but try this!
script.Parent.Touched:connect(function(hit) local player = game.Players:findFirstChild(hit.Parent.Name) if player ~= nil then if script.Parent:findFirstChild("Owner") == nil then local owner = Instance.new("StringValue",script.Parent) owner.Name = "Owner" owner.Value = player.Name elseif script.Parent.Owner.Value ~= player.Name then hit.Parent:BreakJoints() end end end) |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 12:38 AM |
Thank you so much!
I also had a question about safely moving a model from Serverstorage to workspace without the model breaking., Because that is for a car I'm making, and there's a store to purchase it, so, when I press the "Yes" button on the Gui, I did this:
game.ServerStorage.Car:Clone().Parent = game.Workspace
But when I regularly dropped it when it was in the workspace, It didn't work.
I stole YOUR siggy. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 12:39 AM |
Well, It didn't break. Ugh. Sorry about all these errors. Pretty late, and in a hurry to finish something.
I stole YOUR siggy. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 12:46 AM |
SetPrimaryPartCFrame maybe?
I stole YOUR siggy. |
|
|
| Report Abuse |
|
|
| |
|