Hello, how would I not enable an remote event if a specific value isn’t filled with info.
This is a sample of code which is in my script which I expected to work, but doesn’t seem to.
Thanks
if ImgID1.Value == "nil" then
ErrorTL.Visible = true
Error = "ERROR: No image has been selected, automatically set to default."
ImgID1.Value = "rbxassetid://10865155691"
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
if songName.Value == "nil" then
ErrorTL.Visible = true
Error = "ERROR: No song title has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
if ProdBy.Value == "NONE" then
ErrorTL.Visible = true
Error = "ERROR: No producer has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
if WhichStudio.Value == "NONE" then
ErrorTL.Visible = true
Error = "ERROR: No studio has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
if WrroteBy.Value == "NONE" then
ErrorTL.Visible = true
Error = "ERROR: No writer has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
if songName.Value == "nil" then
ErrorTL.Visible = true
Error = "ERROR: No song title has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
So I might be able to help you, but the way you’ve worded the title and the description is making me confused. What I’m getting is that you’re wanting to call a remote event, but if the object you’re checking is nil, then don’t call the remote event. Also, where are you firing and calling you’re remote events?
I am firing the remote right after this code sample
like this:
if ImgID1.Value == "nil" then
ErrorTL.Visible = true
Error = "ERROR: No image has been selected, automatically set to default."
ImgID1.Value = "rbxassetid://10865155691"
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
if songName.Value == "nil" then
ErrorTL.Visible = true
Error = "ERROR: No song title has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
if ProdBy.Value == "NONE" then
ErrorTL.Visible = true
Error = "ERROR: No producer has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
if WhichStudio.Value == "NONE" then
ErrorTL.Visible = true
Error = "ERROR: No studio has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
if WrroteBy.Value == "NONE" then
ErrorTL.Visible = true
Error = "ERROR: No writer has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
if songName.Value == "nil" then
ErrorTL.Visible = true
Error = "ERROR: No song title has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
script.Disabled = true
end
game.ReplicatedStorage.Remotes.CreateSong:FireServer(songName.Value, ImgID1.Value, iinalbum.Value, ProdBy.Value, WrroteBy.Value, SongRate.Value, WhichStudio.Value)
replicatedStorage.Remotes.SetDistValueSC:FireServer(songName.Value)
You could just replace script.Disabled = true to return for the script to stop working if one of the conditions have been met, I think that’s what your trying to achieve here
if WhichStudio.Value == "NONE" then
ErrorTL.Visible = true
Error = "ERROR: No studio has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
return
end
if WrroteBy.Value == "NONE" then
ErrorTL.Visible = true
Error = "ERROR: No writer has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
return
end
if songName.Value == "nil" then
ErrorTL.Visible = true
Error = "ERROR: No song title has been chosen, please try again."
script.Parent.CNTDWN.Disabled = false
return
end
Hello, songName.Value == "nil" will always return false, nil is an “data type” of its own. You’re currently checking for an string containing nil, but not the nil value you’re expecting.