local button = script.Parent local Gui = script.Parent.Parent.Parent.Parent.Parent.Parent local Gui = script.Parent.Parent button.MouseButton1Up:Connect(function() script.Parent.Parent.Visible = false game.Workspace.boo.Playing = true game.Workspace.boo.TimePosition = 0 script.Parent.Parent.Parent.Parent.Parent.Parent.BOO.ImageLabel.ImageTransparency = 0 wait(5) script.Parent.Parent.Parent.Parent.Parent.Parent.BOO.ImageLabel.ImageTransparency = 1 end)
Hello! My name is Ethan, I am starting out on developing on ROBLOX. I was making some code for my game, which is supposed to jumpscare people once pressed. For some reason, the jumpscare image doesn't appear for the whole server, only the person who pressed it. I would like some help as I tried many things to fix this problem. There are images that can help you here
LocalScript
inside Button-- Define Gui stuff local Button = script.Parent -- Grab button... local BooLabel = button.Parent.Parent.Parent.Parent.Parent.BOO.ImageLabel -- ... and label -- Define Workspace stuff local Boo = workspace.boo -- Define Event stuff local RS = game:GetService("ReplicatedStorage") local JumpscareEvent = RS:WaitForChild("JumpscareEvent") -- Grab both items local JumpscareClient = RS:WaitForChild("JumpscareClient") -- Define Player stuff local Players = game:GetService("Players") local LocalPlayer = Players.LocalPlayer -- Grab local player -- Define other Variables local Debounce = false -- Debounce to prevent button spamming -- Connect button Button.Activated:Connect(function() -- When button is clicked or tapped if not Debounce then -- Detect if the button can be pressed Debounce = true -- Set debounce to true to stop further button presses JumpscareEvent:FireServer() -- Fires to server to tell other clients to jumpscare Button.Parent.Visible = false -- Make it invisible Boo:Play() -- Plays the sound BooLabel.Visible = true -- Make it visible wait(5) -- Wait BooLabel.Visible = false -- Make it invisible Debounce = false -- Set it to false so we can press it again end end) -- Connect event JumpscareClient.OnClientEvent:Connect(function(Player) -- Waits for event if Player ~= LocalPlayer then -- If the event wasn't fired by the client Boo:Play() -- Plays the sound BooLabel.Visible = true -- Make it visible wait(5) -- Wait BooLabel.Visible = false -- Make it invisible end end)
In replicated storage, add two RemoteEvent
s, one called JumpscareEvent
, one called JumpscareClient
Script
Put this script in ServerScriptStorage
-- Define Event stuff local RS = game:GetService("ReplicatedStorage") -- Grab Both events local JumpscareEvent = RS:WaitForChild("JumpscareEvent") local JumpscareClient = RS:WaitForChild("JumpscareClient") JumpscareEvent.OnServerEvent:Connect(function(Player) -- Waits for event JumpscareClient:FireAllClients(Player) -- Fires it back out again end)