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

ClickDetector opening a gui works in studio but NOT game?

Asked by 6 years ago
Edited 6 years ago

So I recently put in a simple script where a clickdetector makes a GUI visible. But it does not work in game/online. this is the script: the script is inside the GUI, its a localscript not a server one

plr = game.Players.LocalPlayer
text = plr.PlayerGui.quirklabel.TextLabel
click = game.Workspace.Doctor.Head.ClickDetector

click.MouseClick:connect(function()
    if plr.check.Value == 1 then
        plr.check.Value = plr.check.Value -1
        text.Visible = true
        wait(2)
        text.Text = "Im here to show you your quirk results!"
        wait(2)
        text.Text = "And your quirk is..."
        wait(2)
        local quirk = math.random(1,20)
        if quirk == 1 then
            plr.Quirk.Value = "Super Regeneration"
            text.Text = "Super Regeneration!"
        end
        if quirk == 2 then
            plr.Quirk.Value = "Super Regeneration"
            text.Text = "Super Regeneration!"
        end
        if quirk == 3 then
            plr.Quirk.Value = "Super Regeneration"
            text.Text = "Super Regeneration!"
        end
        if quirk == 4 then
            plr.Quirk.Value = "Super Regeneration"
            text.Text = "Super Regeneration!"
        end
        if quirk == 5 then
            plr.Quirk.Value = "Super Regeneration"
            text.Text = "Super Regeneration!"
            end
            if quirk == 6 then
            plr.Quirk.Value = "Transparency"
            text.Text = "Transparency!"
        end
        if quirk == 7 then
            plr.Quirk.Value = "Transparency"
            text.Text = "Transparency!"
        end
        if quirk == 8 then
            plr.Quirk.Value = "Transparency"
            text.Text = "Transparency!"
        end
        if quirk == 9 then
            plr.Quirk.Value = "Transparency"
            text.Text = "Transparency!"
        end
        if quirk == 10 then
            plr.Quirk.Value = "Transparency"
            text.Text = "Transparency!"
            end
                if quirk == 11 then
            plr.Quirk.Value = "Half Hot Half Cold"
            text.Text = "Half Hot Half Cold!"
        end
        if quirk == 12 then
            plr.Quirk.Value = "Half Hot Half Cold"
            text.Text = "Half Hot Half Cold!"
        end
        if quirk == 13 then
            plr.Quirk.Value = "Half Hot Half Cold"
            text.Text = "Half Hot Half Cold!"
        end
                        if quirk == 14 then
            plr.Quirk.Value = "Explosion"
            text.Text = "Explosion!"
        end
        if quirk == 15 then
            plr.Quirk.Value = "Explosion"
            text.Text = "Explosion!"
        end
        if quirk == 16 then
            plr.Quirk.Value = "Explosion"
            text.Text = "Explosion!"
        end
                            if quirk == 17 then
            plr.Quirk.Value = "Electrification"
            text.Text = "Electrification!"
        end
        if quirk == 18 then
            plr.Quirk.Value = "Electrification"
            text.Text = "Electrification!"
        end
        if quirk == 19 then
            plr.Quirk.Value = "Electrification"
            text.Text = "Electrification!"
            end
            if quirk == 20 then
                plr.Quirk.Value = "One For All"
                text.Text = "One For All!"
            end
            wait(0.8)
            plr.Character.Humanoid.Health = 0
            text.Visible = false
end
end)

0
is it a local script or server abnotaddable 920 — 6y
0
are you using FE? User#5423 17 — 6y
0
It's a localscript, and Im not using FE Wutsinhower 23 — 6y
0
Can you check if the event is being ran by adding in some prints. User#5423 17 — 6y
View all comments (7 more)
0
Just did, and its not being ran Wutsinhower 23 — 6y
0
I used to have problems with click detectors working in studio but not in game as well. Its pretty frustrating! movsb 242 — 6y
0
I think this would fix it: Instead of using connect , use Connect becuase connect is depracated. phxtn 154 — 6y
0
what?? I thought :Connect was deprecated! movsb 242 — 6y
0
I think click detectors can only be activated with server scripts abnotaddable 920 — 6y
0
It did not work, I tried server scripts, local scripts, and :Connect Wutsinhower 23 — 6y
0
try using a text button instead of a click detector if you're using a Gui MrDragonTaker 0 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

Try making all ":connect" into ":Connect"

0
Lol, you making a hero academia game? Cool User#17125 0 — 6y
0
so I just make the c capitalized? Wutsinhower 23 — 6y
0
It didn't work. Wutsinhower 23 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

code should be in a server script in the head of the doctor with the click detector like this . Code:

local click = script.Parent:WaitForChild("ClickDetector")

click.MouseClick:Connect(function(plr) --plr is the player who clicked, its the only way to do it in server scripts
    local text = plr.PlayerGui.quirklabel.TextLabel
    if plr.check.Value == 1 then
        --code
    end
end)
0
It still only works in Studio. And I don't know why, theres no F9 errors. Wutsinhower 23 — 6y

Answer this question