generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Question

Previous Thread :: Next Thread 
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
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
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
02 Jun 2015 12:22 AM
Hellp.

I stole YOUR siggy.
Report Abuse
Rukiryo is not online. 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
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
02 Jun 2015 12:28 AM
so

if hit.Parent:FindFirstChild("Humanoid") then

I stole YOUR siggy.
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
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 is not online. 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
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
02 Jun 2015 12:31 AM
Ugh Confusing, what about the rest of the script?

I stole YOUR siggy.
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
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
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
02 Jun 2015 12:33 AM
Excuse my grammar errors, didn't notice them.

I stole YOUR siggy.
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
02 Jun 2015 12:34 AM
*A little bit more efficient checking

I stole YOUR siggy.
Report Abuse
Rukiryo is not online. 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
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
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
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
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
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
02 Jun 2015 12:46 AM
SetPrimaryPartCFrame maybe?

I stole YOUR siggy.
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
02 Jun 2015 12:55 PM
Bump.

I stole YOUR siggy.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image