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

I can't make a gui appearwho pressed a button through local and server scripts what do I do?

Asked by 5 years ago
Edited by DanzLua 5 years ago

Okay, so basically what I want to do is make a gui appear as soon as you press a model's button which has a click detector, however for this I need to make a local script and server script communicate with remotefired but whenever I join the game it automatically enables the GUI for all please help. This is the server script:

function onClicked()
    script.Parent.Parent.LOUD1.BrickColor = BrickColor.new("Black")
    script.Parent.Parent.LOUD2.BrickColor = BrickColor.new("Black")
    script.Parent.Parent.LOUD3.BrickColor = BrickColor.new("Black")
    script.Parent.Parent.Union2.Smoke.Enabled = true
end 

script.Parent.ClickDetector.MouseClick:connect(onClicked)

local hiEvent = Instance.new("RemoteEvent")
    hiEvent.Parent = game.ReplicatedStorage
    hiEvent.Name = "hiEvent"

local function onPlayerAdded(player)
    hiEvent:FireClient(player)

end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

and this is the local script:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui", 500)
local hiEvent = ReplicatedStorage:WaitForChild("hiEvent")
local weewoo = Instance.new("ScreenGui", playerGui)
local tint = Instance.new("Frame", weewoo)
local blur = Instance.new("ImageLabel", weewoo)
    weewoo.Name = "weewoo"
    blur.Name = "Blur"
    tint.Name = "Tint"
    playerGui.weewoo.Enabled = false
    tint.BackgroundColor3 = Color3.fromRGB(64,111,52)
    tint.BackgroundTransparency = 0.6
    tint.Size = UDim2.new(1,0,1,0)
    blur.Size = UDim2.new(1,0,1,0)
    blur.ImageTransparency = 0.2
    blur.BackgroundTransparency = 1
    blur.Image = "rbxassetid://204446257"
local function onhiEventFired()
weewoo.Enabled = true
tint.Visible = true
blur.Visible = true
wait(90)
weewoo.Enabled = false
blur.Visible = false
tint.Visible = false

end
hiEvent.OnClientEvent:Connect(onhiEventFired())

1 answer

Log in to vote
0
Answered by 5 years ago

You're calling your function when you try to connect the event

hiEvent.OnClientEvent:Connect(onhiEventFired())

Should be

hiEvent.OnClientEvent:Connect(onhiEventFired)

You did it right the first time, so I can only assume that you don't understand how it works. I'd just look into events and functions a little bit more.

0
But now when I try it after changing it to that it doesn't actually pop up the gui anymore when the button is pressed Vyridius 0 — 5y
0
The hardest thing about this is i want the gui to put up when an ingame model button is pressed not as soon as you join Vyridius 0 — 5y
0
I mean, the other thing is that you can't listen for clickdetectors on the server User#6546 35 — 5y
0
So is there anyway to make it work? Vyridius 0 — 5y
View all comments (2 more)
0
Listen to the clickdetectors on the client? Duh User#6546 35 — 5y
0
Listen to the clickdetectors on the client? Duh. User#6546 35 — 5y
Ad

Answer this question