A
A
Andrei St2021-12-23 22:43:43
Lua
Andrei St, 2021-12-23 22:43:43

How to make the Beam event return when the player exits the game?

Greetings, I started writing a script for playing in Roblox Studio, the essence of the script is that when a player enters the game, he sees a beam of arrows where he needs to go, when he passes a certain area in the Part or how to say touches it, the beam disappears for all players in that including for me, but when a player leaves the game, the beam does not appear for those who entered the game, tell me how to fix the situation?

I need the beam to appear every time when the one who touched it left the game.

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local Active = game.Workspace.BeamArrow.PartActive
local invs = game.Workspace.BeamArrow.PartInvs

local start = Instance.new("Attachment")
start.Name = "start"
start.Parent = HumanoidRootPart

local Beam = Instance.new("Beam")
Beam.Name = "Beam"
Beam.Parent = workspace
Beam.Texture = "rbxassetid://136011733"
Beam.TextureLength = 6
Beam.TextureMode = "Wrap"
Beam.TextureSpeed = 0.8
Beam.FaceCamera = true
Beam.Attachment0 = start
Beam.Attachment1 = game.Workspace.BeamArrow.Part1.Attachment1
Beam.Color = ColorSequence.new(Color3.fromRGB(0,255,0),Color3.fromRGB(255,0,0))
Beam.Width0 = 3
Beam.Width1 = 3



Active.Touched:Connect(function(player) -- "player" is the part that touched the part.
  local Humanoid = player.Parent:FindFirstChild("Humanoid") -- Declaring that the object contains a part called Humanoid.
  if Humanoid then -- Check if it contains a humanoid. And if true, do.
    Beam.Enabled = true
  end
end)

invs.Touched:Connect(function(player)
  local Humanoid = player.Parent:FindFirstChild("Humanoid")
  if Humanoid then
    Beam.Enabled = false
  end
end)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question