Hey all,
I’m currently making a horror game, and I want a different number to be sent back when the player wins and loses. I have a remoteEvent named “TeleportToMain” in ReplicatedStorage
that, when fired to the server, decides the number, and teleports you back to the main game with the number as the TeleportData
. The function also needs a survived
parameter, if its true, it sends back the number + 1
, if not, it sends -1
.
However, if I send it from the LocalScript
responsible to handle things when you win (basically the win script), it fires normally. but when I try the same with the LocalScript
responsible for jumpscares (the game over script), it doesn’t seem to actually fire it. I’ve added some prints to check out what’s happening, and it seems the Client side works fine, but it doesn’t get picked up on the server at all. I tried changing the parameters in the loss script to be the exact same line of code as the win one, but nothing happens. Do you happen to know what’s the problem?
- Loss script:
local event3 = game.ReplicatedStorage.JumpscareEnd
event3.OnClientEvent:Connect(function()
local jumpScare = player.PlayerGui:WaitForChild("Jumpscare")
jumpScare.Frame.BackgroundColor3 = Color3.new(1, 1, 1)
jumpScare.Enabled = true
local Tween = TweenProperty(jumpScare.Frame, TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), "BackgroundColor3", Color3.new(0, 0, 0))
Tween:Play()
Tween.Completed:Wait()
local Tween2 = TweenProperty(jumpScare.Frame.YouDied, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), "TextTransparency", 0)
Tween2:Play()
Tween2.Completed:Wait()
task.wait(2)
-- problem [
print("Teleporting")
game.ReplicatedStorage.TeleportToMain:FireServer(true)
print("Fired event")
--problem ]
end)
- Win script: (to show you that it’s the same line of code)
event.OnClientEvent:Connect(function()
game.ReplicatedStorage.NightEnded:Fire()
gui.Enabled = true
encourage.Visible = false
Time.Visible = false
encourage.Transparency = 1
main.Transparency = 1
main.Visible = true
local tweenAppear = Ts:Create(main, TweenInfo.new(1), {BackgroundTransparency = 0})
tweenAppear:Play()
tweenAppear.Completed:Wait()
workspace.Sounds.MainBeep:Play()
wait(0.4)
for i = 1, 9 do
wait(0.175)
alarmAppear(Time)
end
Time.Visible = true
task.wait(2)
encourage.Visible = true
local tweenAppear2 = Ts:Create(encourage, TweenInfo.new(1), {TextTransparency = 0})
tweenAppear2:Play()
task.wait(3)
game.ReplicatedStorage.TeleportToMain:FireServer(true) -- Right here
end)
Like I said, both of these are LocalScripts, The loss script is in StarterPlayerScripts
,
and the other one is in a ScreenGui in StarterGui
. (I’m guessing the issue might be here)
Any help appreciated!