Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I need help with a script I've been making for my game, as it is not working. Could anybody help?

Asked by 3 years ago
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

0
you're only changing the ui for the player who clicked Pupppy44 671 — 3y
0
Iterate the playerlist and change the GUI for every player on it jokeycraft777 5 — 3y
0
jokeycraft777 That still won't work User#30567 0 — 3y
0
is it a local script? catsalt29 57 — 3y
0
catsalt29 it is not a local script, I know this because I work on the game too. Ryanroooo 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

1. 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)

2. Create events

In replicated storage, add two RemoteEvents, one called JumpscareEvent, one called JumpscareClient

3. Server 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)
0
Thanks for the help! I'll be sure to try it, and I'll update you if something doesn't go to plan. I forgot to say that, it was a dialog that popped up when you pressed the button. Should I completely remove that, and replace it with this script? Or should I put it in the "Yes" button? hakerethan 10 — 3y
0
Hi. I did everything you said, and unfortunately nothing happened. I found a few errors in your script (you forgot to capitalise "Button") and still wasn't working. Just curious; did you even test the script before you posted this? I cannot seem to get it working. Maybe I can add you to the team create for more of your assistance. Thanks! - Ethan hakerethan 10 — 3y
0
Are there any errors? User#30567 0 — 3y
Ad

Answer this question