Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I am trying to make a rock door explode with specific things on my character?

Asked by 6 years ago
Edited 6 years ago

~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~

01BodyVel = Instance.new("BodyVelocity")
02WALLorDOOR = script.Parent.Parent.WallToBrake
03FourArms = game.Players.LocalPlayer.Character.Head.face.Texture
04function onTouch(hit)
05    if FourArms == "rbxassetid://2784052807" then
06        BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake1
07        BodyVel.Velocity = Vector3.new(0, -15, 0)
08        BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake2
09        BodyVel.Velocity = Vector3.new(0, -15, 0)
10        BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake3
11        BodyVel.Velocity = Vector3.new(0, -15, 0)
12        BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake4
13        BodyVel.Velocity = Vector3.new(0, -15, 0)
14        BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake5
15        BodyVel.Velocity = Vector3.new(0, -15, 0)
View all 32 lines...
0
Please put your code within a code block. It's the lua symbol when you try to edit your question. Rheines 661 — 6y
0
I fixed the indentation. TheeDeathCaster 2368 — 6y
0
because you are using local player on a server script theking48989987 2147 — 6y
0
try telling a parent to get the local kid theking48989987 2147 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

01local BodyVel = Instance.new("BodyVelocity")
02local WALLorDOOR = script.Parent.Parent.WallToBrake
03function onTouch(hit)
04 
05    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
06 
07    if plr then
08        local char = plr.Character
09        local FourArms = char.Head.face.Texture
10        if FourArms == "rbxassetid://2784052807" then
11            BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake1
12                BodyVel.Velocity = Vector3.new(0, -15, 0)
13                BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake2
14                BodyVel.Velocity = Vector3.new(0, -15, 0)
15                BodyVel.Parent = game.Workspace.RockBuilding.WallToBrake.Brake3
View all 35 lines...
Ad

Answer this question