I have tried to fix this by myself over the course of two days now, and it has never seemed to work. I'm just going to leave the exact code I'm using and ask what is wrong with it, then I'll be on my merry way. Here is a brief overview of what I'm doing. The game chooses a number from one to eight. The number chosen determines which "He" is going to be visible. "He" is a hunched over black figure with a non - closing jaw. "He" is a union, and in a group with a part I named "HitBox", which extends a great distance if front of "Him". I named each model "HIM1(HIM2, + etc, until HIM8)" Whenever a "Him" is visible, the script inside the "HitBox" from that model is enabled. This is the script:
plr = game.Players.LocalPlayer
canAttack = true
script.Parent.Touched:connect(function(part)
local h = part.Parent:FindFirstChild("Humanoid")
if h ~= nil then
if canAttack == true then
canAttack = false
game.Players.LocalPlayer.Character.Humanoid.Health = 0
workspace.Randomizer.Sound:Play()
print("Jumpscare Activated")
game.Players.LocalPlayer.JumpScare.Value = true
wait(7)
canAttack = true
end
end
end)
Next, I put a LocalScript into the StarterGui, titled "JumpscareScript".
plr = game.Players.LocalPlayer
local jumpscare = Instance.new("BoolValue")
jumpscare.Value = false
jumpscare.Name = "JumpScare"
jumpscare.Parent = plr
cam = workspace.CurrentCamera
function Jumpscare()
plr.JumpScare.Value = false
wait(2)
plr.Character.Humanoid.Health = 0
cam.CameraType = "Scriptable"
cam. CFrame = workspace.JumpScareCam. CFrame
workspace.JumpScareCam.Sound.Playing = true
wait(2)
game.Lighting.Dark.Enabled = true -- This causes the screen to go dark.
cam.CameraType = "Custom"
cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
workspace.PurpleDoor.CanCollide = true --Ignore this. These are just doors that
workspace.PurpleDoor.Transparency = 0 --could have been opened by the player,
workspace.Exit.CanCollide = true --so that on their deaths the doors close
workspace.Exit.Transparency = 0 --again.
workspace.RedDoor.CanCollide = true --|
workspace.RedDoor.Transparency = 0 --|
workspace.BlueDoor.CanCollide = true --|
workspace.BlueDoor.Transparency = 0 --`
end
workspace.Randomizer.Sound.Played:connect(Jumpscare)
The "Sound" played when the "HitBox" is touched in the first script has a greater purpose, as when it is played, according to the LocalScript, it causes the function to activate. In the studio, the result is the camera being shoved right up into "His" face and an equally terrifying screeching noise (and the player's death, of course) ; however, online, the result is nothing. I would just like to know what I did wrong, how to fix it, and why it is the solution. This is literally the LAST thing I need to do before the game is released, and this is my first project. This is the first installment of a series called "Meta Minigames", in which the struggles of my friends in real life are twisted and put into horror game form. This one is called "Kalissa's Minigame", and it covers abuse, and it contains a bit of lore for a game series I will be working on after I complete this one. This next series will benefit greatly from this, too. Thank you! :P

1 comment
must be in localscript in startergui, otherwise game.players.localplayer doesn't work