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

Works in Studio, not Client?

Asked by 8 years ago

I know this is a common question. But when I try it in studio, the TextButton works. In client however, nothing...

ap = require(script.Parent.Parent.TrelloAPI)  
local Board = ap:GetBoardID("Admittance")
local List = ap:GetListID("Admitted",Board)
script.Parent.MouseButton1Click:connect(function()
    if game.Players:FindFirstChild(script.Parent.Parent.Patient.Text) == nil then
        script.Parent.Text = "Please enter a valid name"
        wait(2)
        script.Parent.Text = "Send report"
    else 
        if script.Parent.Parent.Reason.Text == "" then
            script.Parent.Text = "Please enter a valid reason"
            wait(2)
            script.Parent.Text = "Send report"
        else
            script.Parent.Text = "Submitted"
            wait(5)
            script.Parent.Parent.Parent.Admit.Visible = false
            script.Parent.Parent.Parent.Button.Visible = true
ap:AddCard(script.Parent.Parent.Patient.Text,script.Parent.Parent.Reason.Text,List,"","top")    
        end
    end
end)

1 answer

Log in to vote
-1
Answered by
legosweat 334 Moderation Voter
8 years ago

You had a mix of if's and else's in there, so I cleaned it all up..(Might have been the problem) Plus I made the AddCard Event a variable!

Script:

ap = require(script.Parent.Parent.TrelloAPI)  
local Board = ap:GetBoardID("Admittance")
local List = ap:GetListID("Admitted",Board)
local debounce = false -- just so they dont spam click the submit button

script.Parent.MouseButton1Click:connect(function() -- button connection
    if debounce == false then -- click filter
    debounce = true
    local check = game.Players:FindFirstChild(script.Parent.Parent.Patient.Text)
    if check == nil then -- checks if nil
        script.Parent.Text = "Please enter a valid name"
        wait(2)
        script.Parent.Text = "Send report"
    elseif script.Parent.Parent.Reason.Text == "" then
            script.Parent.Text = "Please enter a valid reason"
            wait(2)
            script.Parent.Text = "Send report"
    else
            script.Parent.Text = "Submitted"
            wait(5)
            script.Parent.Parent.Parent.Admit.Visible = false
            script.Parent.Parent.Parent.Button.Visible = true
            local card = ap:AddCard(script.Parent.Parent.Patient.Text,script.Parent.Parent.Reason.Text,List,"","top")    
    end
    debounce = false
    end
end)

Hope this works!

0
Is there a reason you didn't indent some things inside the if on line 7? GoldenPhysics 474 — 8y
0
@Golden, cuz yolo legosweat 334 — 8y
Ad

Answer this question