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 5 years ago
Edited 5 years ago

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

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

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?
--]]
0
Please put your code within a code block. It's the lua symbol when you try to edit your question. Rheines 661 — 5y
0
I fixed the indentation. TheeDeathCaster 2368 — 5y
0
because you are using local player on a server script theking48989987 2147 — 5y
0
try telling a parent to get the local kid theking48989987 2147 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 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.

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)
Ad

Answer this question