So I have added a portion to my arrest script, and everything works up to the point where when Player1 goes to interact, the animation that plays is played on Player1, but it’s meant to play the animation on Player2 to arrest them.
How do I go about playing the animation on specifically the player that is getting arrested?
Here is my original code:
local mouse = game.Players.LocalPlayer:GetMouse()
local RS = game:GetService('RunService')
local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Interact = PlayerGui:FindFirstChild('Main').Interact
local PlayerInfo = PlayerGui:FindFirstChild('Main').PlayerInfo
local UserInputService = game:GetService('UserInputService')
local Fill = PlayerGui:FindFirstChild('Main').Interact.Fill
local ClickNoise = PlayerGui:FindFirstChild('Main').Interact.ClickNoise
local Prompt = PlayerGui:FindFirstChild('Main').Interact.Prompt
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local DistanceRequirement = 10
local TimeToPickUp = .5
local hastarget
local isInteracting = false
local isAttached = false
local groupMembership = false
if Player:IsInGroup(6140174) then
groupMembership = true
end
mouse.Move:connect(function()
Interact.Position = UDim2.new(0, mouse.X + 15, 0, mouse.Y +5)
PlayerInfo.Position = UDim2.new(0, mouse.X + 15, 0, mouse.Y +5)
end)
local CheckTarget = coroutine.wrap(function()
while wait(0.1) do
local target = mouse.Target -- defines target as whatever the mouse is on
if target then -- if target exists
if target.Parent:FindFirstChild("Humanoid") then
local TargetPlayer = game.Players:GetPlayerFromCharacter(target.Parent)
print("Mouse is on Torso")
PlayerInfo.Visible = true
PlayerInfo.Username.Text = target.Parent.Name
if TargetPlayer:IsInGroup(6140174) then -- PG
PlayerInfo.Allegiance.Text = "[PRAETORIAN]"
PlayerInfo.FactionLogo.Image = "https://www.roblox.com/asset?id=7229681784"
elseif TargetPlayer:IsInGroup(6124305) then -- SPQR
PlayerInfo.Allegiance.Text = "[SPQR]"
PlayerInfo.FactionLogo.Image = "https://www.roblox.com/asset?id=7229677957"
else
PlayerInfo.Allegiance.Text = "[OUTSIDER]"
PlayerInfo.FactionLogo.Image = "http s://www.roblox.com/asset?id=0"
end
else
PlayerInfo.Visible = false
end
if target.Name == "PG" then
PlayerInfo.Visible = true
PlayerInfo.Allegiance.Text = "[PRAETORIAN]"
PlayerInfo.Username.Text = target.Name
PlayerInfo.FactionLogo.Image = "https://www.roblox.com/asset?id=7229681784"
end
if target.Name == "SPQR" then
PlayerInfo.Visible = true
PlayerInfo.Allegiance.Text = "[SPQR]"
PlayerInfo.Username.Text = target.Name
PlayerInfo.FactionLogo.Image = "https://www.roblox.com/asset?id=7229677957"
end
if target.Name == "OUTSIDER" then
PlayerInfo.Visible = true
PlayerInfo.Allegiance.Text = "[OUTSIDER]"
PlayerInfo.Username.Text = target.Name
PlayerInfo.FactionLogo.Image = "https://www.roblox.com/asset?id=0"
end
if (target.Name == "Right Arm" or target.Name == "Left Arm") and Player:DistanceFromCharacter(mouse.Hit.p) <= DistanceRequirement and target.Parent ~= Player.Character then --if mouse hovers over left or right arm
isInteracting = true
print("Using Interaction")
Prompt.Text = "Handcuff " .. target.Parent.Name
local TargetPlayer = game.Players:GetPlayerFromCharacter(target.Parent) --targetc is the player of the target. It's getting the player.
Interact.Visible = true -- Interact Image Label turns visible, showing the circle and the textlabel
elseif (target.Name == "Left Leg" or target.Name == "Right Leg") and Player:DistanceFromCharacter(mouse.Hit.p) <= DistanceRequirement and target.Parent ~= Player.Character then
isInteracting = true
print("Using Interaction")
Prompt.Text = "Attach " .. target.Parent.Name.. "'s legs"
Interact.Visible = true
elseif (target.Name == "Leather") and Player:DistanceFromCharacter(mouse.Hit.p) <= DistanceRequirement then
isInteracting = true
print("Using Interaction")
Prompt.Text = "Click and hold to collect leather."
Interact.Visible = true
else
isInteracting = false
Fill:TweenSizeAndPosition (UDim2.new(0, 0, 0, 0), UDim2.new(.5, 0, .5, 0), "Out", "Linear", 0, true)
Interact.Visible = false
end
--local TargetPlayer = game.Players:GetPlayerFromCharacter(target.Parent)
--if TargetPlayer then
-- print(TargetPlayer)
--end
else
--print("nothing is being hovered on")
end
--print(Fill.Size)
print(isInteracting)
if Fill.Size.X.Scale == 96 then
print("Fill's size is equal to 96")
--Fill:TweenSizeAndPosition (UDim2.new(0, 0, 0, 0), UDim2.new(.5, 0, 0.5, 0), "Out", "Linear", 0, true)
--print(Fill.Size)
end
end
end)
local isUp = false
local AnimationHandcuffed = PlayerGui:FindFirstChild('LocalScriptVinny').AnimationHandcuffed
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local AnimationID = "697009153"
local CharAnimation
mouse.Button1Down:Connect(function()
isUp = true
Fill.Visible = true
if isInteracting == true then
if Fill.Visible then
Fill:TweenSize(UDim2.new(0, 96, 0, 95), "Out", "Linear", TimeToPickUp, true, function()
ClickNoise:Play()
print("Tween Completed")
isAttached = true
print("Is Attached == true")
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://697009153"
local Track = Humanoid:LoadAnimation(AnimationHandcuffed)
Track:Play()
end)
end
end
end)
mouse.Button1Up:Connect(function()
Interact.Visible = false
Fill:TweenSizeAndPosition (UDim2.new(0, 0, 0, 0), UDim2.new(0.5, 0, 0.495, 0), "Out", "Linear", 0, true)
print("mouse up")
end)
Here is the result of what’s happening: