|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 22 Mar 2012 04:48 PM |
| Fixed.. thanks again for the help! |
|
|
| Report Abuse |
|
|