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 » Scripting Helpers
Home Search
 

Re: Arrest not working correctly

Previous Thread :: Next Thread 
OneWhoCreates is not online. OneWhoCreates
Joined: 29 Jun 2011
Total Posts: 1230
22 Mar 2012 03:23 PM
This script is inside a hopperbin in starterpack. It works by clicking on a player with your mouse. The tool works but the leaderstats parts are not working and I havent been able to figure out the correct method. there is no error in output when testing it.

function onButton1Down(mouse)
local hit=mouse.Target
if hit~=nil then
if hit.Parent:findFirstChild("Humanoid")~=nil then
hit.Parent.leaderstats.D.Value = hit.Parent.leaderstats.D.Value + 4
hit.Parent.leaderstats.C.Value = 0
hit.Parent.TeamColor = game.Teams.Prisoner.TeamColor
hit.Parent.Torso.CFrame=CFrame.new(Vector3.new(134, 236, 249.1))
hit.Parent.Humanoid.Health = 0

end
end
end

function onSelected(mouse)
mouse.Button1Down:connect(function () onButton1Down(mouse) end)
end
script.Parent.Selected:connect(onSelected)
Report Abuse
L2000 is not online. L2000
Joined: 03 Apr 2008
Total Posts: 77448
22 Mar 2012 03:51 PM
You're trying to find the leaderstats and TeamColor values inside of the character; if you put in a part to get the player, then this will work correctly.

function onButton1Down(mouse)
local hit=mouse.Target
if hit~=nil then
if hit.Parent:findFirstChild("Humanoid")~=nil then
local player = game.Players:playerFromCharacter(hit.Parent)
player.leaderstats.D.Value = player.leaderstats.D.Value + 4
player.leaderstats.C.Value = 0
player.TeamColor = game.Teams.Prisoner.TeamColor
hit.Parent.Torso.CFrame=CFrame.new(Vector3.new(134, 236, 249.1))
hit.Parent.Humanoid.Health = 0
end
end
end
function onSelected(mouse)
mouse.Button1Down:connect(function () onButton1Down(mouse) end)
end
script.Parent.Selected:connect(onSelected)
Report Abuse
OneWhoCreates is not online. OneWhoCreates
Joined: 29 Jun 2011
Total Posts: 1230
22 Mar 2012 04:32 PM
Thanks L2000. now the player that is clicked on receives what they should.


There is one more thing that i need in the script.

I need the owner of the arrest " the one doing the clicking of the mouse"
to receive:

A.Value + 1


This is the part that keeps confusing me in this script the most.


This is what i have so far and its 100% working:


function onButton1Down(mouse)
local hit=mouse.Target

if hit~=nil then
if hit.Parent:findFirstChild("Humanoid")~=nil then
local player = game.Players:playerFromCharacter(hit.Parent)

if player.leaderstats.C.Value <= 0 then return end
if player.leaderstats.C.Value > 0 then

player.leaderstats.D.Value = player.leaderstats.D.Value + 4
player.leaderstats.C.Value = 0
player.TeamColor = game.Teams.Prisoner.TeamColor
hit.Parent.Torso.CFrame=CFrame.new(Vector3.new(134, 236, 249.1))
hit.Parent.Humanoid.Health = 0

end
end
end
end
function onSelected(mouse)
mouse.Icon = "rbxasset://textures\\GunCursor.png"
mouse.Button1Down:connect(function () onButton1Down(mouse) end)
end
script.Parent.Selected:connect(onSelected)
Report Abuse
OneWhoCreates is not online. OneWhoCreates
Joined: 29 Jun 2011
Total Posts: 1230
22 Mar 2012 04:48 PM
Fixed.. thanks again for the help!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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