Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
GigsD4X committed Apr 10, 2017
2 parents 63c5922 + e482e00 commit 8d90d22
Show file tree
Hide file tree
Showing 3 changed files with 2,060 additions and 2,000 deletions.
28 changes: 24 additions & 4 deletions SyncAPI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1438,8 +1438,18 @@ end;
-- Keep current player updated in tool mode
if ToolMode == 'Tool' then

-- Set current player
Player = Players:GetPlayerFromCharacter(Tool.Parent);
-- Set current player if in backpack
if Tool.Parent and Tool.Parent:IsA 'Backpack' then
Player = Tool.Parent.Parent;

-- Set current player if in character
elseif Tool.Parent and Tool.Parent:IsA 'Model' then
Player = Players:GetPlayerFromCharacter(Tool.Parent);

-- Clear `Player` if not in possession of a player
else
Player = nil;
end;

-- Stay updated with latest player operating the tool
Tool.AncestryChanged:Connect(function (Child, Parent)
Expand All @@ -1449,8 +1459,18 @@ if ToolMode == 'Tool' then
return;
end;

-- Update current player
Player = Players:GetPlayerFromCharacter(Parent);
-- Set `Player` to player of the backpack the tool is in
if Parent and Parent:IsA 'Backpack' then
Player = Parent.Parent;

-- Set `Player` to player of the character holding the tool
elseif Parent and Parent:IsA 'Model' then
Player = Players:GetPlayerFromCharacter(Parent);

-- Clear `Player` if tool is not parented to a player
else
Player = nil;
end;

end);

Expand Down
Loading

0 comments on commit 8d90d22

Please sign in to comment.