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

Click Detector Shop Click Part? Filtering Enabled

Asked by 6 years ago

Basically, I'm making a game and am learning scripting a bit still. Now I never really have much experience with FE but know a bit about it. So What I want to do is simply make it where you click the part and the GUI appears. Thing is it works fine in the studio with a server test, but when i close it and click it again it doesn't work. Any ways to fix this or something that may help?

Layout: https://i.imgur.com/AdQdPcc.png

Script

script.Parent.Clicky.MouseClick:connect(function(plr)
    local Shop = script.Parent.Shop
    print("Went through")
    if plr.PlayerGui:FindFirstChild("Shop") == nil then
        local Cloned = Shop:Clone()
        Cloned.Parent = plr.PlayerGui
    end
end)

3 answers

Log in to vote
0
Answered by 6 years ago

Also, if you want to learn about remote events and functions, you can visit these links and learn about them.

Remote Events and Functions on roblox wiki This is good if you like to read.

YouTube Tutorial on Remote Events I personally like this tutorial, but if you want to go deeper into FE scripting, I'd suggest learning how to secure your remotes with tables etc.

I hope this helped you get into FE scripting. Good luck on your games!

Ad
Log in to vote
2
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

No need to do this server-side at all, just use the ClickDetector client-side and enable or disable the GUI.

Furthermore, player's GUIs cloned client-side (i.e. from game.StarterGui) are not replicated to the server, so they would always "not exist" from the point of view of the server.

The server should never care or try to care about a player's GUIs, as it takes away a useful level of abstraction / separation.

RBXScriptSignal:connect() is deprecated, you should prefer RBXScriptSignal:Connect().

In Play Solo mode in Studio, there is no separation between the client and server. Try Test Server mode for this behavior when needed.

The Wiki says that you must handle ClickDetector.MouseClick server-side, but the Wiki is wrong.

Think about it. Even when using a ClickDetector, since you're handling it server-side this would mean you're sending mouse clicks to the server, for the server to do work, all just for the server to tell the client that clicked a button to open a GUI. No need, waste of bandwith and adds latency.

0
Read this and the one that Sharkeedub posted going to try to script it now Hopefully I learned enought! Sergiomontani10 236 — 6y
Log in to vote
0
Answered by 6 years ago

Ok i figured it out. I simply added a Remoteevent to the textbutton

This just for any future scripters

Everything is in the textbutton

Add a remotevent called "Exit"

Local Script:

script.Parent.MouseLeave:connect(function()
    script.Parent.IsIn.Value = false
    script.Parent.Text = "XClose GUIX"
    wait()
    script.Parent.Text = "XClose GU"
    wait()
    script.Parent.Text = "XClose G"
    wait()
    script.Parent.Text = "XClose "
    wait()
    script.Parent.Text = "XClose"
    wait()
    script.Parent.Text = "XClos"
    wait()
    script.Parent.Text = "XClo"
    wait()
    script.Parent.Text = "XCl"
    wait()
    script.Parent.Text = "XC"
    wait()
    script.Parent.Text = "X"
end)

script.Parent.MouseEnter:connect(function()
    script.Parent.IsIn.Value = true
    script.Parent.Text = "XC"
    wait()
    script.Parent.Text = "XCl"
    wait()
    script.Parent.Text = "XClo"
    wait()
    script.Parent.Text = "XClos"
    wait()
    script.Parent.Text = "XClose"
    wait()
    script.Parent.Text = "XClose G"
    wait()
    script.Parent.Text = "XClose GU"
    wait()
    script.Parent.Text = "XClose GUI"
    wait()
    script.Parent.Text = "XClose GUI"
    wait()
    script.Parent.Text = "XClose GUIX"
    wait(20)
    if script.Parent.IsIn.Value == true then
        script.Parent.Text = "Are you going to click or nah?"
        wait(1)
        script.Parent.Text = "XClose GUIX"
    end
end)

script.Parent.MouseButton1Click:connect(function()
    script.Parent.Exit:FireServer()
end)
script.Parent.Exit.OnServerEvent:Connect(function()
    script.Parent.Parent.Parent:Destroy()
end)

Answer this question