OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 26 Mar 2017 04:30 PM |
victimPlayerChar.Humanoid.HealthChanged:connect(function()
victimPlayerChar is changing while the script is running. However, it doesn't seem to notice when the new victimPlayerChar's health changes. Any suggestions? Thanks.
--Online |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 26 Mar 2017 04:32 PM |
What's the rest of the code?
|
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 26 Mar 2017 04:35 PM |
It's like 6 scripts total to make it work. The rest of this specific script though follows.
--Open Source Dynamic Handcuff Script: Made by OnlineOne --DO NOT MESS WITH ANYTHING THAT DOESN'T HAVE A COMMENT NEXT TO IT UNLESS YOU KNOW WHAT YOU'RE DOING
local parent = script.Parent local handle = parent.Handle local activeTransparency = 0.5--Transparency of the tool when it's debouncing local activeTime = 1--Time tool will interact when hit for local debouncingTime = 5--Debouncing time local debouncing = false local isLinked = false local dominantPlayer = game.Players.LocalPlayer local dominantPlayerChar = dominantPlayer.Character local ART = game.ReplicatedStorage:WaitForChild("AddRemoveTools") local AT = game.ReplicatedStorage:WaitForChild("AddTools") local RT = game.ReplicatedStorage:WaitForChild("RemoveTools") local ST = game.ReplicatedStorage:WaitForChild("SetTeam") local T = game.ReplicatedStorage:WaitForChild("Teleport") local victimPlayer = game.Workspace.HumModel local victimPlayerChar = game.Workspace.HumModel local active local firstLoop = false
parent.Equipped:connect(function(mouse) local event mouse.Button1Down:connect(function() if debouncing == false then if not victimPlayer:FindFirstChild("Humanoid") or victimPlayer:FindFirstChild("Humanoid").Health <= 0 then isLinked = false if victimPlayer.Parent then if victimPlayer:FindFirstChild("Humanoid").Health <= 0 then local link = victimPlayer:FindFirstChild(dominantPlayer.Name) link:Destroy() end end end if isLinked == false then debouncing = true active = true dominantPlayerChar = dominantPlayer.Character handle.Transparency = activeTransparency dominantPlayerChar.Humanoid.MaxHealth = 25000 dominantPlayerChar.Humanoid.Health = 25000 event = handle.Touched:connect(function(hit) event:disconnect() if game.Players:FindFirstChild(hit.Parent.Name) and game.Workspace:FindFirstChild(hit.Parent.Name) then victimPlayer = ga############################################ victimPlayerChar = game.Workspace:FindFirstChild(hit.Name) if victimPlayer and active and dominantPlayerChar.Humanoid.Health > 0 then firstLoop = true active = false victimPlayerChar = game.Workspace:FindFirstChild(victimPlayer.Name) local link = game.ReplicatedStorage.Link:Clone() link.Parent = game.Workspace:FindFirstChild(victimPlayer.Name) link.Name = dominantPlayer.Name link.Disabled = false isLinked = true victimPlayerChar.Humanoid.MaxHealth = 25##### victimPlayerChar.Humanoid.Health = 25##### local isVictim = game.ReplicatedStorage.IsVictim:Clone() isVictim.Parent = victimPlayer local scriptClone = ART:Clone() scriptClone.Parent = victimPlayerChar local valueClone = RT:Clone() valueClone.Value = victimPlayer.Name valueClone.Parent = scriptClone scriptClone.Disabled = false end end end) wait(activeTime) active = false handle.Transparency = 0 dominantPlayerChar.Humanoid.MaxHealth = 100 dominantPlayerChar.Humanoid.Health = 100 wait(debouncingTime) debouncing = false elseif isLinked == true then debouncing = true local link = victimPlayerChar:FindFirstChild(dominantPlayer.Name) local isVictim = victimPlayer.IsVictim link:Destroy() isVictim:Destroy() local scriptClone = ART:Clone() scriptClone.Parent = victimPlayerChar local valueClone = AT:Clone() valueClone.Value = victimPlayer.Name valueClone.Parent = scriptClone scriptClone.Disabled = false victimPlayerChar.Humanoid.MaxHealth = 100 victimPlayerChar.Humanoid.Health = 100 victimPlayer = game.Workspace.HumModel victimPlayerChar = game.Workspace.HumModel wait(debouncingTime) isLinked = false debouncing = false end end end) end)
function freeVictim() if victimPlayer.Parent ~= game.Workspace and dominantPlayerChar.Humanoid.Health <= 0 then local link = victimPlayerChar:FindFirstChild(dominantPlayer.Name) local isVictim = victimPlayer.IsVictim wait(0.25) victimPlayerChar.Humanoid.MaxHealth = 100 link:Destroy() isVictim:Destroy() local scriptClone = ART:Clone() scriptClone.Parent = victimPlayerChar local valueClone = AT:Clone() valueClone.Value = victimPlayer.Name valueClone.Parent = scriptClone scriptClone.Disabled = false end end
dominantPlayerChar.Humanoid.HealthChanged:connect(function() freeVictim() end)
victimPlayerChar.Humanoid.HealthChanged:connect(function()----------doesnt notice when this happens. after you fix, remove lines 31-36 if victimPlayer.Parent ~= game.Workspace then if victimPlayerChar.Humanoid.Health <= 0 then local link = victimPlayerChar:FindFirstChild(dominantPlayer.Name) victimPlayerChar.Humanoid.Health = 100 link:Destroy() victimPlayer.IsVictim:Destroy() victimPlayer.Prisoner.Value = true local scriptClone = ST:Clone() ST.Parent = victimPlayerChar local teleport = T:Clone() T.Parent = scriptClone T.Value = false end end end)
game.Players.PlayerRemoving:connect(function(playerLeft) if playerLeft == dominantPlayer then freeVictim() elseif playerLeft == victimPlayer then playerLeft.IsVictim.Value = true isLinked = false end end)
--Online |
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
| |
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
| |
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
| |
|
|
| 28 Mar 2017 07:02 PM |
Is this script inside victimPlayerChar?
|
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 28 Mar 2017 07:04 PM |
It's inside of the Handcuff tool which is a child of victimPlayerChar, so in a way, yes.
--Online |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2017 07:19 PM |
Scripts can only be ran in ServerScriptService and Workspace (i'm sure there is more so please correct me anyone).
|
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 28 Mar 2017 07:22 PM |
That's not quite true, but either way, this script is in Workspace...
--Online |
|
|
| Report Abuse |
|
|
| |
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
| |
|