Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Works in Studio, not Client?

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

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!

2 comments

0

Is there a reason you didn't indent some things inside the if on line 7?

0

@Golden, cuz yolo

This discussion is preserved as it was. New answers, comments, and votes are closed.