So I have been struggling to figure this out. There is this gripping tool I use where if somebody clicks on another player it will grab where they clicked. As of lately, this tool is not seen from both ways. Only the person who clicked can see what is going on. What can I do to fix this?
The code:
---define variables---
Wait(); local playa=game.Players.LocalPlayer;--the player local char;--the character local anim;--the animation script local torso;--the character torso local humanoid;--the character humanoid local right=false;--left or right arm? local controls;--the controls GUI for iOS users local mouse=playa:GetMouse();--the players mouse local crouched=false;--is the player crouched down or not?
---define functions---
--welds two parts together the way they are function stick(x,y) local weld = Instance.new("Weld") weld.Part0 = x weld.Part1 = y weld.Name = "Grip" local HitPos = x.Position local CJ = CFrame.new(HitPos.unit) local C0 = x.CFrame:inverse() *CJ local C1 = y.CFrame:inverse() * CJ weld.C0 = C0 weld.C1 = C1 weld.Parent = y local tag=Instance.new("ObjectValue",x); tag.Name="Grabbed"; weld.Changed:connect(function(p) if p=="Parent" then tag:Destroy(); end end ); return weld; end
--changes a weld to look at a certain part function ChangeWeld(name,part,offset) local weld=torso[name]; --[[ p0=part0.CFrame c0=c0 p1=part1.CFrame c1=c1
p1*c1 == p0*c0
c1 == p1:inverse()*p0*c0
c0 == p0:inverse()*p1*c1
--]]
local desired_p1=CFrame.new(--the CFrame that we want the arm to be at
(weld.Part0.CFrame*offset).p+(part.Position-(weld.Part0.CFrame*offset).p).unit,--the position we want
part.Position--look at the part
)*
CFrame.Angles(math.pi/2,0,0);--rotate it so that the hand points that way
weld.C0=CFrame.new();--set C0 to identity matrix so it is out of the equation
weld.C1=desired_p1:inverse()*weld.Part0.CFrame;--same equation as shown above
end
repeat Wait(); until playa.Character --set values controls=playa.PlayerGui:findFirstChild("controls"); char=playa.Character; anim=char:findFirstChild("Animate"); torso=char:findFirstChild("Torso"); humanoid=char:findFirstChild("Humanoid"); local la0,la1=torso["Left Shoulder"].C0,torso["Left Shoulder"].C1; local ra0,ra1=torso["Right Shoulder"].C0,torso["Right Shoulder"].C1; local ll0,ll1=torso["Left Hip"].C0,torso["Left Hip"].C1; local rl0,rl1=torso["Right Hip"].C0,torso["Right Hip"].C1; --stop player animation anim.Disabled=true; --set text of GUIs controls.Arm.Text="Arm: "..(right and "Right" or "Left");
--control buttons clicked, Arms controls.Arm.MouseButton1Click:connect(function() right=not right; controls.Arm.Text="Arm: "..(right and "Right" or "Left"); end );
--control buttons clicked, Fall/Stand controls.FS.MouseButton1Click:connect(function() humanoid.PlatformStand=not humanoid.PlatformStand; controls.FS.Text=(humanoid.PlatformStand and "Stand" or "Fall"); end ); --[[ --control buttons clicked, Crouched/Stance controls.Shoot.MouseButton1Click:connect(function() if not crouched then crouched=true; torso["Left Hip"].C0=CFrame.new(); torso["Left Hip"].C1=CFrame.new(-0.5,0.75,1); torso["Right Hip"].C0=CFrame.new(); torso["Right Hip"].C1=CFrame.new(0.5,0.495,1.25)*CFrame.Angles(math.rad(90),0,0); else crouched=false; torso["Left Hip"].C0,torso["Left Hip"].C1=ll0,ll1; torso["Right Hip"].C0,torso["Right Hip"].C1=rl0,rl1; end controls.Shoot.Text=(crouched and "Stance" or "Shoot"); end ); --]]
--release grips controls.Release.MouseButton1Click:connect(function() pcall(function() char["Right Arm"].Grip:Destroy(); end); pcall(function() char["Left Arm"].Grip:Destroy(); end); torso["Left Shoulder"].C0,torso["Left Shoulder"].C1=la0,la1; torso["Right Shoulder"].C0,torso["Right Shoulder"].C1=ra0,ra1; end );
--check for click mouse.Button1Down:connect(function() local obj=mouse.Target;--the object clicked on --check for Humanoid if obj.Parent:findFirstChild("Humanoid") and (obj.Position-char[right and "Right Arm" or "Left Arm"].Position).magnitude<=3 then if right and not char["Right Arm"]:findFirstChild("Grabbed") then pcall(function() char["Right Arm"].Grip:Destroy(); end); ChangeWeld("Right Shoulder",obj,CFrame.new(1,0.5,0)); --create grip stick(obj,char["Left Arm"]); --check if obj has a grip on something else and destroy it if obj:findFirstChild("Grip") then obj.Grip:Destroy(); end --tell obj that it is grabbed elseif not right and not char["Left Arm"]:findFirstChild("Grabbed") then pcall(function() char["Left Arm"].Grip:Destroy(); end); ChangeWeld("Left Shoulder",obj,CFrame.new(-1,0.5,0)); --create grip stick(obj,char["Left Arm"]); --check if obj has a grip on something else and destroy it if obj:findFirstChild("Grip") then obj.Grip:Destroy(); end end end end );
--check for key press mouse.KeyDown:connect(function(key) --switch hand using if key:lower()=="q" then right=false; controls.Arm.Text="Arm: "..(right and "Right" or "Left"); elseif key:lower()=="e" then right=true; controls.Arm.Text="Arm: "..(right and "Right" or "Left"); --release elseif key:lower()=="r" then pcall(function() char["Right Arm"].Grip:Destroy(); end); pcall(function() char["Left Arm"].Grip:Destroy(); end); torso["Left Shoulder"].C0,torso["Left Shoulder"].C1=la0,la1; torso["Right Shoulder"].C0,torso["Right Shoulder"].C1=ra0,ra1; --fall/Stand elseif key:lower()=="z" then humanoid.PlatformStand=not humanoid.PlatformStand; controls.FS.Text=(humanoid.PlatformStand and "Stand" or "Fall"); --[[ --crouch/stance elseif key:lower()=="c" then if not crouched then crouched=true; torso["Left Hip"].C0=CFrame.new(); torso["Left Hip"].C1=CFrame.new(-0.5,0.75,1); torso["Right Hip"].C0=CFrame.new(); torso["Right Hip"].C1=CFrame.new(0.5,0.495,1.25)*CFrame.Angles(math.rad(90),0,0); else crouched=false; torso["Left Hip"].C0,torso["Left Hip"].C1=ll0,ll1; torso["Right Hip"].C0,torso["Right Hip"].C1=rl0,rl1; end controls.Shoot.Text=(crouched and "Stance" or "Shoot"); --]] end end );

1 comment
Immediately, this is because of FE. You have to tell the Server to replicate it using RemoteEvents as it is asked to never replicate what you do. Someone who will answer this question will provide more details.