~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~
BodyVel = Instance.new("BodyVelocity") WALLorDOOR = script.Parent.Parent.WallToBrake FourArms = game.Players.LocalPlayer.Character.Head.face.Texture function onTouch(hit) if FourArms == "rbxassetid://2784052807" then BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake1 BodyVel.Velocity = Vector3.new(0, -15, 0) BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake2 BodyVel.Velocity = Vector3.new(0, -15, 0) BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake3 BodyVel.Velocity = Vector3.new(0, -15, 0) BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake4 BodyVel.Velocity = Vector3.new(0, -15, 0) BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake5 BodyVel.Velocity = Vector3.new(0, -15, 0) WALLorDOOR.Brake1.Anchored = false WALLorDOOR.Brake2.Anchored = false WALLorDOOR.Brake3.Anchored = false WALLorDOOR.Brake4.Anchored = false WALLorDOOR.Brake5.Anchored = false wait(1) script.Boom:Play() wait(3) ----------------------------- WALLorDOOR:GetChildren() WALLorDOOR:Destroy() end end script.Parent.Parent.WallToBrake.Brake1.Touched:Connect(onTouch) --[[This is the script that i try to make but it says this:Workspace.RockBuilding.WallToBrake.Script:3: attempt to index field 'LocalPlayer' (a nil value) That should mean i am not allowed to put local player inside of the script in workspace or? --]]
As the comments said, you can't get the LocalPlayer from a server script. What you can do though is get the character from the parent of the touching part.
local BodyVel = Instance.new("BodyVelocity") local WALLorDOOR = script.Parent.Parent.WallToBrake function onTouch(hit) local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then local char = plr.Character local FourArms = char.Head.face.Texture if FourArms == "rbxassetid://2784052807" then BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake1 BodyVel.Velocity = Vector3.new(0, -15, 0) BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake2 BodyVel.Velocity = Vector3.new(0, -15, 0) BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake3 BodyVel.Velocity = Vector3.new(0, -15, 0) BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake4 BodyVel.Velocity = Vector3.new(0, -15, 0) BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake5 BodyVel.Velocity = Vector3.new(0, -15, 0) WALLorDOOR.Brake1.Anchored = false WALLorDOOR.Brake2.Anchored = false WALLorDOOR.Brake3.Anchored = false WALLorDOOR.Brake4.Anchored = false WALLorDOOR.Brake5.Anchored = false wait(1) script.Boom:Play() wait(3) ----------------------------- WALLorDOOR:GetChildren() WALLorDOOR:Destroy() end end end script.Parent.Parent.WallToBrake.Brake1.Touched:Connect(onTouch)